Redirecting varnish to new backend on the fly

varnishCache1) Change VCL backend config

Go to your vcl file (in my case /etc/varnish/default.vcl). Edit the backend param to point to another server. Also increase the timeouts since it will take longer than accessing localhost.

backend default {
 .host = "";
 .port = "80";
 .connect_timeout = 120s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 60s;

2) Validate VCL script on the fly

sudo varnishd -C -f /etc/varnish/default.vcl

This will notify if any syntax issues exist.


3) Reload the VCL Script without restarting varnish

I utilized:

$varnishadm -T localhost:6082
vcl.load reload01 /etc/varnish/default.vcl 
vcl.use reload01