Survive a Proxy Node Failure
A single SafeSquid node is a single point of failure for every user behind it. When the proxy stops answering, browsing stops — and so does policy enforcement, logging, and the audit trail that proves enforcement happened. Users escalate, and the fastest workaround an impatient administrator reaches for is disabling the proxy entirely. Active-passive high availability removes that pressure. Clients connect to a virtual IP (VIP) that always points at a healthy node. Keepalived moves the VIP on failure in 2–3 seconds; Monit independently restarts a crashed SafeSquid process on either node.Split responsibilities between two tools
Keepalived and Monit solve different problems. They do not conflict — running only one leaves a gap.
Keepalived runs the health-check script every 5 seconds. If SafeSquid is not serving traffic, Keepalived drops the Master’s VRRP priority below the Backup’s and the VIP moves. Monit restarts SafeSquid on the failed node and logs the event.
Match the design to the failure
Prerequisites
- Two SafeSquid instances installed and activated — one Master, one Backup.
- Both nodes on the same subnet, so VRRP advertisements reach both.
- One unused IP address for the VIP. It must not be assigned to any other host or DHCP pool.
- Root or sudo access on both nodes.
- Firewall rules permitting VRRP (IP protocol 112) between the two nodes.
keepalived,monit, andcurlavailable from the distribution repositories.
Install both packages on both nodes
Run this on the Master and the Backup:systemctl.
Create the health-check script
Keepalived runs this script every 5 seconds. A non-zero exit drops the node’s VRRP priority and triggers VIP handover. Create/etc/keepalived/check_safesquid.sh on both nodes:
Configure Keepalived on both nodes
Onlystate and priority differ between the two files. Everything else must match exactly.
- Master node
- Backup node
Write
/etc/keepalived/keepalived.conf:Why the weight is -101
The weight must push the Master’s effective priority below the Backup’s, not merely reduce it.- The Master starts at priority 101.
- On check failure,
weight -101makes the effective priority101 - 101 = 0. 0is below the Backup’s100, so the Backup wins the VRRP election, advertises the higher priority, and the Master releases the VIP.
-60 yields 101 - 60 = 41. That is still below 100, but it does not reliably drive the BACKUP state transition across Keepalived versions. Use -101 so the outcome is unambiguous.
Configure Monit on both nodes
Monit supervises the SafeSquid process and restarts it. It does not touch the VIP — that stays with Keepalived. Write/etc/monit/conf.d/safesquid.monit on both nodes:
Keep
set daemon and set httpd in /etc/monit/monitrc only. Repeating them here produces an address option specified twice error and Monit refuses to start.Start both services
Run on both nodes:proto keepalived tag confirms Keepalived owns the address and will withdraw it automatically on failover. An address without that tag was assigned statically and will not move.
Verify and evidence failover
Confirm the Master state and a passing health check:Test the failover
Open two terminals. Watch the log on the Backup while you stop SafeSquid on the Master.nopreempt keeps the VIP on the Backup after the Master recovers. This avoids a second interruption during business hours. To move the VIP back deliberately, restart Keepalived on the Master: sudo systemctl restart keepalived.Capture HA evidence
Store these artifacts with the change record:- Both
keepalived.conffiles and the health-check script, with a checksum. journalctl -u keepalivedextract covering the tested failover, showing the state transition and gratuitous ARP.ip aoutput before and after failover, showing VIP ownership on each node./var/log/keepalived_check.logand/var/log/monit.logfor the test window.- Client-side proof that browsing resumed through the VIP, plus the SafeSquid access log entries from the surviving node.
- The date of the last tested failover and the named owner of the next test.
Troubleshoot HA failures
File reference
Master and Backup differences
Next steps
- Proxy Clustering - scale enforcement across more than two nodes.
- Configuration Sync - keep policy identical on both HA nodes.
- Disaster Recovery - plan rebuild and restore beyond node failover.

