Nginx and Apache2 are running great but there is only one tiny problem with the visitors ip’s.
Normaly I let my nginx instance do the logging job, but if you let your Apache do it you will get some problems. Apache will see all incoming requests as coming from localhost (127.0.0.1). Right they are all from nginx.
Solution:
1 2 3 4 5 6 | # Install rpaf module for Apache2 aptitude install libapache2-mod-rpaf # Enable it a2enmod rpaf # Restart apache2 /etc/init.d/apache2 restart |
This tells Nginx to forward the original remote IP-address in the header as it proxys ro Apache.
Add this 3 Lines to your nginx.conf or to your enables site config:
1 2 3 | proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
Jan Vladimir Mostert says
Works for me, thanks for the simple solution!!
zeldor says
I hope it worked fine for you;)
bzion says
Impeccable. Merci :)