I have been trying to get a simple health check in haproxy to work. But somehome the haproxy request is differently handled then a curl request, which generates a socket error in haproxy. The health script echos these lines, with this config[2] echo -ne "HTTP/1.1 200 OK\r\n" echo -ne "Content-Length: 0\r\n" echo -ne "\r\n" exit 0 The curl request generates ok, haproxy generates socket error. The haproxy=yes, reuseport=yes do not seem to resolve anything. If stop dovecot and run "dovecot-health-check.sh | nc -l 192.168.10.46 5001" then the haproxy check is ok. So I guess the script is ok. But what is dovecot then doing with it's output when haproxy is requesting it? [1] https://discourse.haproxy.org/t/httpck-on-bash-script-results-in-socket-error/5647/16 [2] service health-check { executable = script -p /usr/local/sbin/dovecot-health-check.sh inet_listener health-check { port = 5001 haproxy = no reuse_port = no } }
Thomas Zajic
2021-Oct-18 04:07 UTC
health check passthrough not 100% in combination with haproxy
* Marc, 17.10.21 01:15> I have been trying to get a simple health check in haproxy to work. But somehome the haproxy request is differently handled then a curl request, which generates a socket error in haproxy. > [...]For stats, you can use "socat" to talk to haproxy's stat socket instead of using its HTTP interface. For example, with "stats socket /var/lib/haproxy/stats" in haproxy's config, you can then do: echo "show stat" | socat - "UNIX-CONNECT:/var/lib/haproxy/stats" Maybe there is a way to also expose your health check status on a local socket instead of an HTTP listener? This would at least eliminate having to deal with missing or superfluous CR/LFs, spaces, etc. Just a thought. HTH, Thomas
Should this be filed as a bug somewhere?> > I have been trying to get a simple health check in haproxy to work. But > somehome the haproxy request is differently handled then a curl request, > which generates a socket error in haproxy. > > The health script echos these lines, with this config[2] > > echo -ne "HTTP/1.1 200 OK\r\n" > echo -ne "Content-Length: 0\r\n" > echo -ne "\r\n" > exit 0 > > The curl request generates ok, haproxy generates socket error. The > haproxy=yes, reuseport=yes do not seem to resolve anything. If stop > dovecot and run "dovecot-health-check.sh | nc -l 192.168.10.46 5001" > then the haproxy check is ok. So I guess the script is ok. But what is > dovecot then doing with it's output when haproxy is requesting it? > > > > [1] > https://discourse.haproxy.org/t/httpck-on-bash-script-results-in-socket- > error/5647/16 > > [2] > service health-check { > executable = script -p /usr/local/sbin/dovecot-health-check.sh > inet_listener health-check { > port = 5001 > haproxy = no > reuse_port = no > } > }