Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website running with nginx and Plack/Starman as upstream. simple configuration looks like:

upstream findmjob {
    server unix:/tmp/findmjob.sock;

server {
  listen       80;

  access_log /;
  error_log  / info;

  root /;
  location / {
    try_files $uri @proxy;
    access_log off;
    expires max;

  location @proxy {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass       http://findmjob;

I have some perl code which returns a redirect. it means it works fine under perl/plack: fayland$ curl -I ''
HTTP/1.0 301 Moved Permanently
Date: Tue, 01 May 2012 06:14:38 GMT
Server: HTTP::Server::PSGI
Server: Perl Dancer 1.3095
Content-Length: 0
Content-Type: text/html; charset=utf-8
X-Powered-By: Perl Dancer 1.3095

as you see it's really with ''.

but when I use the socks and nginx, it returns something like: fayland$ curl -I ''
HTTP/1.1 301 Moved Permanently
Server: nginx/0.7.65
Date: Tue, 01 May 2012 06:15:20 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Location: .com/freelance/GK3bmm+P4RG+2MTa2fVHmw
Content-Length: 0
X-Powered-By: Perl Dancer 1.3095

the http://findmjob is dropped, only .com is left?!

any help is really appreciated.

Updated: upgrade to the latest version fixed it. fayland$ curl -I ''
HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.0
Date: Tue, 01 May 2012 08:22:29 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
X-Powered-By: Perl Dancer 1.3095


share|improve this question
up vote 1 down vote accepted

This is because your upstream defined as 'http://findjob' and default for proxy_redirect is

proxy_redirect   http://findjob /;

And this means that nginx will strip string equal to first arg to proxy_redirect (http://findjob) from proxied Location:.

Use proxy_redirect off; instead to fix this issue. Check documentation for details.

share|improve this answer
Thanks for it. and weird that I upgraded it to the latest version and it fixes too. – Fayland Lam May 1 '12 at 8:23
Well, I think that using upsteam id in this case was a bug in nginx which was worth fixing. – AlexD May 1 '12 at 8:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.