【发布时间】:2011-05-25 21:18:47
【问题描述】:
我在我的服务器 ansel.ms 上运行了 nginx,在 ansel.ms:46156 上运行了一个 node.js 应用程序。
我想设置 nginx,以便它重定向所有内容
ansel.ms/rhythm
到
ansel.ms:46156.
ansel.ms/rhythm/sub/path
应该变成
ansel.ms:46156/sub/path
这是我在可用站点中的文件:
upstream rhythm {
server ansel.ms:46156;
}
server {
listen 80;
server_name ansel.ms www.ansel.ms;
access_log /srv/www/ansel.ms/logs/access.log;
error_log /srv/www/ansel.ms/logs/error.log;
location / {
root /srv/www/ansel.ms/public_html;
index index.html index.htm;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/ansel.ms/public_html$fastcgi_script_name;
}
location /rhythm{
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://rhythm;
proxy_redirect off;
}
}
我不太了解它的作用(proxy_set_header 的东西),我只是从几个来源复制并粘贴了它。
它不起作用。
你能告诉我要改变什么,让它像我上面描述的那样做吗? 谢谢!
【问题讨论】: