Skip to main content

Varnish Frontend

This playbook deploys Varnish as a caching frontend on existing anycast worker nodes. Varnish sits in front of NGINX, caching responses and serving them from the nearest PoP. The full stack is: netactuate-ansible-bgp-bird2 then netactuate-ansible-nginx then this playbook.

Playbook Repository

git clone https://github.com/netactuate/netactuate-ansible-varnish

Configuration

group_vars/all

VariableTypeDefaultDescription
varnish_bind_ipstring0.0.0.0IP Varnish listens on
varnish_portinteger80Port Varnish listens on
varnish_backend_hoststring127.0.0.1Backend server address (NGINX)
varnish_backend_portinteger8080Backend server port
varnish_memorystring256mVarnish cache storage size

Note: Set varnish_bind_ip to 0.0.0.0 to listen on all interfaces. Varnish will be reachable via your anycast IP through the loopback binding configured by the BGP playbook.

When running Varnish in front of NGINX, configure NGINX to listen on the backend port (8080) and Varnish on the frontend port (80).

Deployment

ansible-playbook varnish.yaml

Validation

curl -I http://YOUR_ANYCAST_IP

Look for the Via: header containing varnish and the X-Varnish: header to confirm Varnish is serving. An Age: header with a non-zero value indicates a cache hit.

Need Help?

If you need assistance deploying Varnish, visit our support page.