3

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!

3
  • 1
    Are you sure it isn't your browser's cache problem?
    – user81458
    Jul 5, 2012 at 22:10
  • Hi Tibor, I thought this at first, but definitely not browse cache
    – Gerard
    Jul 5, 2012 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, 2012 at 22:45

1 Answer 1

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .