1
我想配置的Nginx做到以下幾點:Nginx的配置子站點和論壇
- 重定向example.com和www.example.com我的老網站
- www.example.com/論壇或example.com/forum到論壇的網絡服務器(IP)
- 任何其他子域.example.com的,反向代理到Node.js的
我知道下面是不行的,我應該怎麼配置?
server {
listen 80;
server_name www.example.com example.com;
location /forum {
proxy_pass http://<forum ip>/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
return 301 $scheme://www.old-website.com;
}
server {
listen 80;
server_name ~^(.*)\.example\.com $;
location/{
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
的/論壇返回404雖然 –
NVM我的代理之前添加重寫規則,謝謝 –
當加載論壇我得到的所有靜態文件404,因爲它們是請求在裸體域而不是example.com/forum –