I’ve been trying to see if I may find some improvement using varnish in front of Nginx to serve static content, well I’ve not finished the test yet, and will be publishing my results here later.

But, in case you decide to run Nginx in front of a proxy, you will find that all lines in access.log file, will have the IP of the proxy, and not the client IP itself.

To solve that, you need to compile Nginx with Real IP module

Using Real IP module with NGINX

The Real IP module in Nginx will do somehow the same job of libapache2-mod-rpaf if Apache were behind Nginx or other reverse proxy.

OK, so you need to compile Nginx with support for Real IP module, to do that proceed, like in this post: Nginx with gzip-static support, but in this case use this option --with-http_realip_module, instead or together with --with-http_gzip_static_module.

After that, you need to configure /etc/nginx/conf/nginx.conf file, and between http {…} tags, add this

                real_ip_header X-Forwarded-For;

This is valid if Varnish is running in the same computer as Nginx, if not, instead of, use the varnish computer’s IP.