Loadbalancing on squid proxy

PROXYsquid

How I can setup something for some squid users to use another server if the primary server is down?

Best Answer

The easiest way to do this would be to have another squid server on the same network segment, and use heartbeat to share a virtual IP between them. Then you configure the clients to use the VIP, and when the primary server goes down it transparently fails over to the secondary, requiring no change on the user's machine at all.

If you are using Centos/redhat, it's particularly easy. Install the heartbeat package, and modify the two files /etc/ha.d/ha.cf and /etc/ha.d/haresources (assuming real IPs of 1.2.3.11 and 12 for machines A and B respectively, and 1.2.3.10 for the VIP):

on machine A add in ha.cf:

ucast eth0 1.2.3.12

node {fqdn.machine.a} node {fqdn.machine.b}

on machine B add in ha.cf:

ucast eth0 1.2.3.11

node {fqdn.machine.a} node {fqdn.machine.b}

in haresources on both: {fqdn.machine.a} 1.2.3.10/24/eth0

Now restart the heartbeat service on both, configure squid to listen on all interfaces, and you're good to go. This does not fail over if the machine stays up but squid goes down. That is a bit more complicated (though doable).

Related Topic