I'm trying to make sure that when a server goes up after being down (and not active any more) it will be re-enabled automatically.
This is my haproxy.cfg:
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
# daemon
defaults
log global
mode tcp
#retries 3
option tcplog
option dontlognull
option redispatch
no option persist
#balance roundrobin
balance leastconn
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
listen stats 0.0.0.0:9000 #Listen on all IP's on port 9000
mode http
balance
timeout client 5000
timeout connect 4000
timeout server 30000
#This is the virtual URL to access the stats page
stats uri /haproxy_stats
#Authentication realm. This can be set to anything. Escape space characters with a backslash.
stats realm HAProxy\ Statistics
#The user/pass you want to use. Change this password!
stats auth admin:adminpassword
#This allows you to take down and bring up back end servers.
#This will produce an error on older versions of HAProxy.
stats admin if TRUE
# FRONTEND - NON-SSL
frontend www-http
bind *:80
# detect capacity issues in production farm
acl MAIN_not_enough_capacity nbsrv(www-unsecure-backend-proxy) le 2
# failover traffic to backup farm
use_backend www-unsecure-backend-direct if MAIN_not_enough_capacity
default_backend www-unsecure-backend-proxy
# BACKEND - NON-SSL
backend www-unsecure-backend-proxy
mode tcp
server rproxycache01 rpcache01.container:80 check
server rproxycache02 rpcache02.container:80 check
# FALLBACK - NON-SSL
backend www-unsecure-backend-direct
option allbackups
server rproxycache01 rpcache01.container:80 check
server rproxycache02 rpcache02.container:80 check
server frontend01 web01.container:80 check backup
server frontend02 web02.container:80 check backup
so, let's say all the servers are down, whenever one goes back up it should be used, but I've checked in the web interface and all the servers are red.
How can I do it?
Thank you in advance.
Best Answer
I'd say that global setting
retries 3
is causing problems for you. After 3 retries, HAProxy will give up on further checks. See the documentation for retries directive.Since you didn't set inter value, HAProxy will check server availability every 2 seconds. If your server was unavailable for more than 6 seconds, HAProxy will consider it permanently down.
I'd suggest that you comment out
retries 3
line (or set bigger value) and/or adjustcheck inter
value, restart HAProxy and redo the tests.