I have running nginx on my server ansel.ms and a node.js app on ansel.ms:46156.
I want to setup nginx so it redirects everything from
ansel.ms/rhythm
to
ansel.ms:46156.
ansel.ms/rhythm/sub/path
should become
ansel.ms:46156/sub/path
This is my file in sites-available:
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;
}
}
I do not really understand deeply what this does (the proxy_set_header stuff), I only copied & pasted it from several sources.
It doesn't work.
Can you give me a hint what to change so it does what I described above? Thank you!