You have two Enhance app servers behind a single public IP, where “behind” means “DNS round-robins between their two IPs.” A customer’s site hits one of them, the customer logs in, the next request lands on the other server, and the session is gone — they get bounced back to the login page. Or worse: one of the app servers’ Apache goes down at 02:00, DNS still hands its IP to half of incoming clients, and you wake up to a customer who’s been seeing intermittent timeouts for six hours because their browser cached the broken IP. DNS load balancing is a deployment posture, not a load balancer. The real fix is a pair of HAProxy boxes in front, with keepalived for the VIP.
What’s happening
Enhance does not ship a load balancer of its own; the panel assumes you’ll put one in front of the app server tier yourself. The components you need:
- HAProxy — TCP/HTTP load balancer, two instances for HA.
- keepalived — VRRP-based VIP failover so a single virtual IP floats between the two HAProxy nodes.
- A health check that actually reflects whether the app server is serving Enhance traffic — not just
tcp_connect(which succeeds even when Apache is half-dead) and not just HTTP 200 on/(which can lie when PHP-FPM is busy but the static index page still serves). - Session affinity for the customer panel, which uses session cookies for the logged-in user state. Round-robin across app servers without affinity will sign customers out every few seconds.
The end state: two HAProxy hosts (lb01, lb02) sharing one VIP (203.0.113.10). VIP terminates TLS for the panel and customer sites, distributes traffic across N Enhance app servers, sticks logged-in sessions to one backend, fails the VIP to the surviving HAProxy if one dies, and removes a backend automatically if its health check fails.
How to verify
Look at the current Enhance topology — which app servers exist, what they’re listening on:
TOKEN=$(vault kv get -field=value secret/enhance/admin/current)
ORCH="https://panel.example.com"
curl -sH "Authorization: Bearer $TOKEN" "$ORCH/api/app-servers" | \
jq '.app_servers[] | {hostname, ip: .private_ip, web_port: .web_port, sites: .website_count}'
For each app server, sanity-check the health endpoint Enhance exposes:
# Enhance app servers expose /healthz on the internal port
for ip in 10.40.1.11 10.40.1.12 10.40.1.13; do
echo -n "$ip: "
curl -sk --max-time 3 "https://$ip:8443/healthz" || echo "FAIL"
echo
done
{"status":"ok","apache":"ok","mysql":"ok","disk_free_pct":42} is the response shape from a healthy node. If disk_free_pct < 10 or any subsystem is not_ok, the load balancer should route around it.
If you already have HAProxy in place, check what its current view of the backends looks like:
echo "show stat" | socat stdio /run/haproxy/admin.sock | \
awk -F, '$2!="FRONTEND" && $2!="BACKEND" && $1=="enhance_web_back" {print $2, $18, $36}'
# server_name, status, last_check_msg
status: UP everywhere is what you want. If any are DOWN or MAINT, that’s the issue.
VRRP state on each HAProxy host:
# On lb01:
ip addr show ens3 | grep '203.0.113.10' # is the VIP here?
journalctl -u keepalived -n 50 --no-pager
Only one of lb01 / lb02 should have the VIP attached at any moment.
The fix
The installer script — runs on both HAProxy hosts after you set the LB_ROLE variable. Both hosts get the same HAProxy config; only keepalived differs between MASTER and BACKUP:
#!/usr/bin/env bash
# /root/setup-enhance-lb.sh
# Run on lb01 with LB_ROLE=MASTER, on lb02 with LB_ROLE=BACKUP
set -euo pipefail
if [[ "$(id -u)" -ne 0 ]]; then echo "Run as root."; exit 1; fi
LB_ROLE="${LB_ROLE:?set LB_ROLE=MASTER or BACKUP}"
VIP="203.0.113.10"
LB_INTERFACE="ens3"
VRID=51
PEER_LB_IP="" # the other LB's IP, used as unicast peer
# Enhance app server pool (private IPs, web port)
APP_SERVERS=(
"ent-app01 10.40.1.11"
"ent-app02 10.40.1.12"
"ent-app03 10.40.1.13"
)
case "$LB_ROLE" in
MASTER) PRIO=150; STATE=MASTER; PEER_LB_IP="10.40.0.6" ;;
BACKUP) PRIO=100; STATE=BACKUP; PEER_LB_IP="10.40.0.5" ;;
*) echo "LB_ROLE must be MASTER or BACKUP"; exit 1 ;;
esac
echo "==> Installing HAProxy + keepalived"
dnf -y install epel-release
dnf -y install haproxy keepalived socat jq
echo "==> Sysctl for LB"
cat > /etc/sysctl.d/99-haproxy.conf <<'SYSCTL'
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.tcp_max_syn_backlog = 8192
net.core.somaxconn = 4096
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535
SYSCTL
sysctl --system
echo "==> HAProxy config"
mkdir -p /etc/haproxy/ssl /run/haproxy
# Build the backend server list
BACKEND_LINES=""
for entry in "${APP_SERVERS[@]}"; do
name="${entry%% *}"
ip="${entry##* }"
BACKEND_LINES+=$' server '"${name}"' '"${ip}"':8443 ssl verify none check port 8443 inter 3s fall 3 rise 2 cookie '"${name}"$'\n'
done
cat > /etc/haproxy/haproxy.cfg <<EOF
global
daemon
maxconn 16384
log /dev/log local0
stats socket /run/haproxy/admin.sock mode 660 level admin
tune.ssl.default-dh-param 2048
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
defaults
log global
mode http
option httplog
option dontlognull
option redispatch
retries 2
timeout client 60s
timeout server 60s
timeout connect 5s
timeout http-request 15s
timeout http-keep-alive 4s
timeout queue 30s
frontend stats
bind 127.0.0.1:7000
mode http
stats enable
stats uri /
stats refresh 10s
stats admin if LOCALHOST
frontend enhance_web_front
bind :80
bind :443 ssl crt /etc/haproxy/ssl/wildcard.pem alpn h2,http/1.1
http-request redirect scheme https code 301 unless { ssl_fc }
# Pass real client IP forward
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Proto https
http-request set-header X-Real-IP %[src]
default_backend enhance_web_back
backend enhance_web_back
balance leastconn
option httpchk GET /healthz
http-check expect status 200
cookie ENHANCE_LB insert indirect nocache httponly secure
default-server inter 3s fall 3 rise 2 maxconn 1000 on-marked-down shutdown-sessions
${BACKEND_LINES}
EOF
# Place a placeholder cert if no real one exists yet
if [[ ! -f /etc/haproxy/ssl/wildcard.pem ]]; then
openssl req -x509 -newkey rsa:2048 -nodes -days 30 \
-keyout /tmp/placeholder.key -out /tmp/placeholder.crt \
-subj "/CN=placeholder.local" 2>/dev/null
cat /tmp/placeholder.crt /tmp/placeholder.key > /etc/haproxy/ssl/wildcard.pem
chmod 600 /etc/haproxy/ssl/wildcard.pem
rm -f /tmp/placeholder.key /tmp/placeholder.crt
fi
haproxy -c -f /etc/haproxy/haproxy.cfg
echo "==> keepalived config"
cat > /etc/keepalived/keepalived.conf <<EOF
global_defs {
router_id ${HOSTNAME}
enable_script_security
script_user nobody
}
vrrp_script chk_haproxy {
script "/usr/bin/pgrep -x haproxy"
interval 2
weight 2
fall 2
rise 2
}
vrrp_instance VI_ENHANCE {
state ${STATE}
interface ${LB_INTERFACE}
virtual_router_id ${VRID}
priority ${PRIO}
advert_int 1
unicast_src_ip $(ip -o -4 addr show ${LB_INTERFACE} | awk '{split($4,a,"/"); print a[1]; exit}')
unicast_peer {
${PEER_LB_IP}
}
authentication {
auth_type PASS
auth_pass CHANGE_ME_VRRP
}
virtual_ipaddress {
${VIP}/32 dev ${LB_INTERFACE}
}
track_script {
chk_haproxy
}
}
EOF
echo "==> Firewall"
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-protocol=vrrp
firewall-cmd --reload
echo "==> Enable + start"
systemctl enable --now haproxy keepalived
echo
echo "==> Listeners"
ss -lntp | grep -E ':(80|443|7000)\b' || true
echo
echo "==> VRRP state (10s after start)"
sleep 12
ip addr show ${LB_INTERFACE} | grep "${VIP}" && echo "VIP is on this host" || echo "VIP is on peer"
echo
echo "==> HAProxy backend state"
echo "show stat" | socat stdio /run/haproxy/admin.sock | \
awk -F, '$2!="FRONTEND" && $2!="BACKEND" && $1=="enhance_web_back" {print $2, $18}'
Run on the master:
LB_ROLE=MASTER bash /root/setup-enhance-lb.sh
Then on the backup:
LB_ROLE=BACKUP bash /root/setup-enhance-lb.sh
DNS — point panel.example.com and the wildcard *.shared.example.com at the VIP 203.0.113.10, not at any individual app server’s IP. The app server IPs become a private-network detail that customers and operators never touch.
A failover test you can run any time:
# On the current MASTER:
systemctl stop keepalived
# From an external host:
while true; do
curl -sk --max-time 2 https://panel.example.com/api/version | jq -r .version
sleep 1
done
# Should show 1-2 failed requests then resume from the BACKUP
Bring keepalived back up to return to the MASTER. The MASTER reclaims the VIP because of its higher priority.
A health-check note: the httpchk GET /healthz above expects Enhance’s healthz endpoint to return non-200 when the backend is genuinely degraded. Confirm this on each app server:
# Simulate Apache failure
systemctl stop httpd
curl -sk https://10.40.1.11:8443/healthz # should now return 503 or 500
# Restart
systemctl start httpd
If healthz keeps returning 200 even with Apache down, you need a richer health endpoint — write a small CGI or wrapper that actually queries Apache’s status, MySQL’s status, and disk free space, and returns 503 if any are degraded. The whole HA story depends on health checks that fail closed.
Two structural rules: never put the LB and the Enhance app server on the same host — colocation kills the HA story because the failure that takes out the app server takes out the LB with it. And the cookie used for session affinity (ENHANCE_LB above) must be marked Secure and HttpOnly; the affinity is a routing concern, not a security boundary, but a leaked LB cookie still tells an attacker which backend a customer is pinned to.
Standing up a proper HA front end for an Enhance fleet, including TLS termination, sticky sessions, real health checks, and failover drills, is part of how we run hosting under Cloud Compute with Managed Cloud Ops discipline. Plan a fronting-layer review if your panel is still leaning on DNS round-robin.