Hi experts!
I have been using HAProxy for quite some time now and with most of the applications i run through it I have no problems at all. There are two sites however, that give me a lot of headaches. When testing in single user mode (just me on HAProxy and the webserver) i can run into a reproduceable situation that the server just “stops answering”. First few clicks work - then chrome is stuck “(pending)”. What i see in the logfiles is a wrong backend being selected in those requests. there is no configuration change and from the firewall i don’t see any packets going from HAProxy to the actual web server
here the log:
working:
2023-04-21T09:53:53.998735+02:00 xxxxxxx haproxy[16677]: ::ffff:10.x.x.6:52986 [21/Apr/2023:09:53:53.996] fe_generic_ssl_termination~ be_sdr/xxhsdr01_80 0/0/1/1/2 200 6318 - - ---- 16/6/0/0/0 0/0 {sdr.xxxx.xxxx.xx|Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Sa} "GET https://sdr.xxxx.xxxx.xx/yyyyyyyyyy/zzzzzzzzzz.uuu HTTP/2.0"
not working:
2023-04-21T10:58:54.190458+02:00 xxxxxxx haproxy[16677]: ::ffff:10.x.x.6:54556 [21/Apr/2023:10:58:14.185] fe_generic_ssl_termination~ be_default_https/dummy 0/30003/-1/-1/40004 503 0 - - sC-- 8/2/0/0/3 0/0 {sdr.xxxx.xxxx.xxxx|Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Sa} "GET https://sdr.xxxx.xxxx.xx/yyyyyyyyyy/zzzzzzzzzz.uuu HTTP/2.0"
I tried various timeout settings but i always come back to the same problem- it just stops working after a few clicks. The timeout will most likely come from the non existing backend that i use to deter connection attempts with invalid hostnames.
Here is a sanitized config containing all the way through to this backend
defaults
mode http
log global
option httplog
option redispatch
no option httpclose
retries 3
maxconn 10000
timeout connect 10s
timeout client 30s
timeout server 30s
frontend ssl_frontend
bind :::443 v4v6
mode tcp
option tcplog
log global
timeout client 6h
tcp-request inspect-delay 2s
tcp-request content accept if { req_ssl_hello_type 1 }
acl client_attempts_ssh payload(0,7) -m bin 5353482d322e30
use_backend xxxxxxx_ssh if client_attempts_ssh
use_backend openvpn if !{ req.ssl_hello_type 1 } !{ req.len 0 }
use_backend be_xxxxx_vpn if { req.ssl_sni -m end vpn.xxxx.xxxx.xx }
use_backend be_rdp_tsc if { req.ssl_sni -m end rdgateway.xxxx.xx }
default_backend be_generic_ssl_termination
backend be_generic_ssl_termination
mode tcp
server loopback abns@fe_generic_ssl_termination send-proxy-v2
frontend fe_generic_ssl_termination
bind abns@fe_generic_ssl_termination accept-proxy ssl crt-list /etc/haproxy/crt-list.conf ca-file xxxxxxxxxx.pem alpn h2,http/1.1
mode http
option forwardfor except 127.0.0.0/8
capture request header Host len 32
capture request header User-Agent len 100
log global
# Use letsencrypt backend for certificate validation
acl is_well_known path -m reg ^/.well-known/acme-challenge/
use_backend be_letsencrypt if is_well_known
use_backend be_service1 if { ssl_fc_has_crt } { ssl_fc_sni -i service1.xxxx.xxxx.xx }
use_backend be_service2 if { ssl_fc_has_crt } { ssl_fc_sni -i service2.xxxx.xxxx.xx }
use_backend be_service3 if { ssl_fc_has_crt } { ssl_fc_sni -i service3.xxxx.xxxx.xx }
use_backend be_service4 if { ssl_fc_has_crt } { ssl_fc_sni -i service4.xxxx.xxxx.xx }
use_backend be_service6 if { ssl_fc_sni -i service6.xxxx.xxxx.xx }
use_backend be_sdr if { ssl_fc_has_crt } { ssl_fc_sni -i sdr.xxxx.xxxx.xx }
use_backend be_service5 if { ssl_fc_has_crt } { ssl_fc_sni -i service5.xxxx.xxxx.xx }
default_backend be_default_https
backend be_default_https
server dummy 10.0.0.1:80
backend be_sdr
balance source
mode http
server xxhsdr01_80 xxhsdr01.xxxx.xxxx.xx:80 verify none no-check maxconn 100
could anyone help me by pointing out obvious configuration errors or any way on how to debug the backend selection process? In the bad cases haproxy always chooses be_default_https/dummy although the be_sdr backend is available, has 0 out of 100 connections and all checking is disabled by now.
Thanks + best regards
Michael