Как перенаправить address.com/foo/bar на address.com : port / bar с nginx?

У меня запущен nginx на моем сервере ansel.ms и приложение node.js на ansel.ms:46156.

Я хочу настроить 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), я только скопировал и вставил его из нескольких источников.

Это не работает.

Не могли бы вы подсказать, что нужно изменить, чтобы он делал то, что я описал выше? Спасибо!

13
задан hcs42 6 February 2011 в 21:04
поделиться