我有一个用于/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
,知道如何解决这个问题?
无需进入 nginx 配置详细信息:您的论坛应用程序是否知道它的根 url 现在是 localhost/forums?而不是“localhost/”?