ดังนั้นฉันจึงมีเว็บไซต์หลักที่สร้างด้วยการตอบสนองและด่วนตอนนี้ฉันต้องการเพิ่มส่วนบล็อกในเว็บไซต์ของฉันที่สร้างด้วย next.js อย่างไรก็ตาม ฉันไม่ต้องการโฮสต์มันในบางอย่างเช่น blog.example.com
ฉันค่อนข้างจะเป็นเจ้าภาพ example.com/blog
.
ฉันใช้ Digital Ocean Droplet ที่ใช้งาน Ubuntu 18.04 และ nginx ฉันได้ดูคำถามที่คล้ายกันเป็นของฉัน แต่ฉันไม่สามารถทำงานนี้ได้ ฉันได้วางการกำหนดค่า nginx ของฉันด้านล่างและเพิ่มเครื่องหมายรหัสในบล็อกตำแหน่งที่ไม่ทำงาน
เซิร์ฟเวอร์ {
รูท /var/www/html;
ดัชนี index.html index.htm index.nginx-debian.html;
server_name example.com;
ที่ตั้ง / {
proxy_set_header X-ส่งต่อ-สำหรับ $proxy_add_x_forwarded_for;
proxy_set_header โฮสต์ $http_host;
proxy_set_header X-NginX-Proxy จริง;
proxy_http_version 1.1;
proxy_set_header อัพเกรด $http_upgrade;
proxy_set_header อัพเกรดการเชื่อมต่อ;
proxy_max_temp_file_size 0;
proxy_pass http://my_nodejs_upstream/;
ปิด proxy_redirect;
proxy_read_timeout 240 วินาที;
}
ที่ตั้ง /api {
proxy_pass http://localhost:3001;
}
สถานที่ / บล็อก {
รูท / บล็อก;
}
ฟัง [::]:443 ssl ipv6only=เปิด;
ฟัง 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
รวม /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
ฉันยังใหม่กับการกำหนดค่า nginx ดังนั้นขออภัยหากเป็นข้อผิดพลาดง่ายๆ ขอขอบคุณ.