WordPress Varnish Cache Age 0

Varnish with cache age 0 means that varnish did not serve the content from cache.

To solve this, edit your sudo nano /etc/varnish/default.vcl

paste this in that file.

After that restart varnish service,

sudo service varnish restart

you may check your varnish status here

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 127.0.0.1 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.

🙂