Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

haproxy

We are using HAProxy to forward incoming TCP connections to a separate server that uses a raw TCP. The issue that we are seeing is that the client connection is accepted and then closed rather then rejected immediately. Since we have enabled a health check is there any way for HAProxy to unbind from the port so that the initial 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
like image 692
Aron Avatar asked Jun 05 '13 21:06

Aron


1 Answers

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

acl site_dead nbsrv lt 1
tcp-request connection reject if site_dead

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

nbsrv documentation

acl documentation

tcp-reject documentation

like image 128
ty. Avatar answered Nov 01 '22 08:11

ty.