I am using haproxy 1.7.9 to do load balancing for my web server.
I am facing issue with back-end heath check. It is showing 404 error but i can access the web site directly without error.
Here is my back end config:
backend b_http_hvmv
mode http
option httpclose
balance roundrobin
option httpchk HEAD / HTTP/1.1\r\nHost:\ mv.xx.yyy.com
option log-health-checks http-check expect status 200
http-check disable-on-404 cookie SERVERID insert indirect nocache
server hvlappswebp01 10.239.72.223:80 cookie hvlappswebp01 check
server hvlappswebp02 10.239.72.192:80 cookie hvlappswebp02 check
There is a difference between the request that a browser sends and this requests. First of all, you are using HEAD, so you’d have to see whether your webserver actually responds to HEAD requests with a 200 OK message.
Use curl -v to find the correct request to send to your webserver.
Why your webserver is responding with 404 is not really something haproxy can possibly now. If you want to match the browsers behavior, you need to replicate that request.
In your capture we see a 500 return code. Maybe you have to check the error logs of your web server.
Also, to test your health check you could try something like this directly from your haproxy server : curl -iv -H "Host: xx.yy.zzz.com" "http://10.239.39.14"
and check the response.