我的问题与此非常相似:nginx proxy pass redirects ignore port
我正在使用 nginx 1.0.14。
我希望能够通过 ssh 隧道进入我的 Django 网站,以便我可以远程工作。我在我的个人电脑上测试了一个简单的 Django 项目,使用非常简单的 nginx 配置(启动器,默认)。我隧道和重定向返回端口号作为 url 的一部分。所以我确定这不是 Django 问题。主要是我的nginx配置。
这是相关的部分。
server {
listen 80;
server_name localhost 127.0.0.1;
server_name_in_redirect off;
# location other services go here
location ~ /forum/(.*)$ {
#rewrite ^(.*):(.*)/forum(.*)$ /$2 last;
#rewrite ^(.*)$ http://localhost:8000/$1;
#rewrite ^/forum(.*)$ $1 break;
# the forum service runs as local, listens to 8000 port...
proxy_pass http://localhost:8000;
proxy_redirect default;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
那么如果我 …