Setup Varnish - Multiple Ipaddress

From Brian Nelson Ramblings
Revision as of 21:46, 18 March 2014 by Brian (Talk | contribs) (Set Varnish to Listen on Multiple IP's)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Set Varnish to Listen on Multiple IP's

By default, varnish will listen on every ipaddress you add to the server.

Only listen to specific ipaddresses

Say you have a server with 3 ip's and you only want 2 to use varnish. You will have to edit the /etc/sysconfig/varnish file

vim /etc/sysconfig/varnish

And change the -a flag to include both ips' comma separated

Find

-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \

Replace with

-a 192.168.0.1:80,192.168.0.2:80 \

Over all it will look like

DAEMON_OPTS="-a 192.240.163.202:80,192.240.163.19:80 \
            -f ${VARNISH_VCL_CONF} \
            -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
            -t ${VARNISH_TTL} \
            -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
            -u varnish -g varnish \
            -S ${VARNISH_SECRET_FILE} \
            -s ${VARNISH_STORAGE}"

Now you only have varnish listening to only a few of the ips on the server not all or 1.

Additional Articles