I’m using HAProxy to load balance traffic to an application running on a single machine. I want to define a primary and a fallback backend, both pointing to the same server (same app, same machine), but I want HAProxy to treat them as logically distinct servers — so that if the primary fails (based on a health check), it will fail over to the fallback.
backend backend-1
option httpchk GET /is_healthy
http-check expect status 200
server primary1 app-host.local-1:14240 check port 8080
server primary2 app-host.local-2:14240 check port 8080
server fallback1 app-host.local-1:14240 backup check disabled
server fallback2 app-host.local-2:14240 backup check disabled
In this setup:
- Port 8080 runs a lightweight health-check service (this logically just marks un-healthy)
- Port 14240 is the actual application.
- I intentionally return a non-200 on /is_healthy to simulate failure.
- The fallback has health checks disabled, but should still receive traffic when both primary fails.
When the health check fails, HAProxy logs show no servers available, and I get a 503 Service Unavailable. It seems HAProxy doesn’t actually treat the fallback as a distinct server because the IP and port are the same.