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
| Variable | Type | Default | Description |
|---|---|---|---|
varnish_bind_ip | string | 0.0.0.0 | IP Varnish listens on |
varnish_port | integer | 80 | Port Varnish listens on |
varnish_backend_host | string | 127.0.0.1 | Backend server address (NGINX) |
varnish_backend_port | integer | 8080 | Backend server port |
varnish_memory | string | 256m | Varnish cache storage size |
Note: Set
varnish_bind_ipto0.0.0.0to 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.