我有一个反向代理/forums
设置如下:
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1: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;
}
location /forums {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4567/;
proxy_redirect off;
# Sockect.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
它可以工作,有点,当我尝试转到时,localhost/forums
我可以看到该页面,但是所有的静态内容都是 404,如果我尝试单击链接,例如 /login,它会带我到localhost/login
而不是localhost/forums/login
,有什么想法可以解决这个问题吗?
答案1
无需了解 nginx 配置细节:您的论坛应用程序是否知道它的根 URL 现在是 localhost/forums?而不是“localhost/”?