Nginx reverse proxy not passing through root (/)

apache-2.2debiannginxreverse-proxy

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!

Best Answer

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!