Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have set up Nginx as a reverse proxy to Apache on a web server.

Nginx is listening on 0.0.0.0:80 and passing through to 127.0.0.1:81

This all seems to be working fine, except when I first load the site at the root level (i.e. http://example.com/) nginx is not passing through to Apache, instead displaying the 'Welcome to Nginx!' page.

If I CTRL+F5 it will pass through to Apache, also passes through to Apache if I load any other pages on the site..

My vhost is set up as follows:

server {
    listen       0.0.0.0:80;
    server_name domain.com.au;
    access_log /var/log/nginx/default.access.log;

    location / {
    proxy_pass http://127.0.0.1:81/;
    include /etc/nginx/proxy_params;
}
}

My proxy_params is set up as follows:

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Any help on this one is greatly appreciated!

share|improve this question
1  
Are you sure it isn't your browser's cache problem? –  Tibor Jul 5 '12 at 22:10
    
Hi Tibor, I thought this at first, but definitely not browse cache –  Gerard Jul 5 '12 at 22:36
    
FYI I just added a new vhost and it's working fine. The problematic site is a WordPress site (as is the new one that's working), though I can't see how this would be causing the issue as it's not running PHP just proxying to Apache?? –  Gerard Jul 5 '12 at 22:45

1 Answer 1

Ok, managed to fix this by adding the following to proxy_params:

proxy_redirect off;

Not really sure why this would fix it, but it did!

share|improve this answer

Your Answer

 
discard

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.