I have the following setup to process certain domains with rails via unicorn:

http {
    # ...
    upstream unicorn_server {
        # This is the socket we configured in app's config unicorn.rb
        server unix:/var/www/foo.bar.com/tmp/sockets/unicorn.sock fail_timeout=0;
    }
    # ...
}


server {
    listen foo.bar.com:80;
    server_name foo.bar.com;

    # ...

    location / {
        if (!-f $request_filename) {
            proxy_pass http://unicorn_server;
            break;
        }
    }
}

While Chrome does handle it properly (shows the rails app), Firefox and possibly other browsers are redirected to http://unicorn_server (the unicorn upstream is not invoked). Can you please tell me what am I missing here?

nginx: nginx version: nginx/1.0.10, unicorn v4.2.0

link|improve this question

50% accept rate
feedback

1 Answer

Seems like

proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

are not included by default. That did the job.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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