How can I make HAProxy reject TCP connections when all server servers are down

We use HAProxy to forward incoming TCP connections to a separate server that uses raw TCP. The problem we see is that the client connection is accepted, then closed, and then rejected immediately. Since we have enabled health checks, is there a way for HAProxy to unlink the port so that the original connection fails?

listen custom_forward mode tcp bind *:11144 default-server inter 10m fastinter 20s downinter 1m maxconn 100 server custom_server hostname:10144 check 
+7
source share
1 answer

You want to explicitly reject the connection if the backend servers are down:

 acl site_dead nbsrv lt 1 tcp-request reject if site_dead 

Or acl site_dead nbsrv(backend_name) lt 1 , where backend_name is the name of another backend.

Nbsrv documentation

acl documentation

tcp-reject documentation

+10
source

All Articles