Tag Archives: server

How to get the original IP address in Apache2 behind Varnish

I’m having Varnish as a frontend and then running Apache through reverse proxy. The Apache logs become full of just a single IP address, the accesses from the Varnish server – usually if you are running both on the same server.

No more GeoIP decisions on the backend or any other feature by remote address.

But we know that Varnish passes along the original client IP address on a HTTP header named X-Forwarded-For to the backend server. It would be awesome if Apache could deal with that,

Fortunately there is already a module that injects the IP on a special header to the HTTP request to Apache: mod_remoteip

  1. Install mod_remoteip
  2. Enable the module
  3. Edit your apache2 configuration file
  4. Add this line at the end of the file
  5. Restart Apache service

You should now get the client’s real IP address instead of varnish IP address.