Health check showing 404 error

Hi Experts,

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

Can someone help me?

Thanks!

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.

Thanks Lukastribus,

I ran the command that you mention. Seem it is ok

curl -v http://spkms.fushan.fihnbb.com

  • About to connect() to xxxx port 80 (#0)
  • Trying 10.239.39.14…
  • Connected to xxxx (10.239.39.14) port 80 (#0)

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host:xxxx
Accept: /

< HTTP/1.1 200 OK
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Server: Microsoft-IIS/8.5
< X-AspNetMvc-Version: 5.2
< X-Frame-Options: SAMEORIGIN
< X-AspNet-Version: 4.0.30319
< Set-Cookie: __RequestVerificationToken=h2vkVLB2AfR7ZZElqFd_y0cXt6JYADvBEz5AgPQBbrs0JmdRvOS5C_BMpY3jlheqA1ar9R2B_oJ-hMNMljcGqAYSa8amTjcowvEG5Mxow601; path=/; HttpOnly
< X-Powered-By: ASP.NET
< Date: Wed, 19 Dec 2018 09:28:34 GMT
< Content-Length: 4078

Which is a different request altogether. One is a GET request, the other one is a HEAD request.

How do you want to health check exactly?

I tried to use GET method but the same result:

backend b_http_spkms
mode http
option httpclose
balance roundrobin
option httpchk GET / “HTTP/1.1\r\nHost: xx.yy.zzz.com
option log-health-checks
http-check expect status 200
http-check disable-on-404
cookie SERVERID insert indirect nocache
server hvspauthp01 10.239.39.14:80 cookie hvspauthp01 check
server hvspauthp02 10.239.72.16:80 cookie hvspauthp02 check
haproxystatics
#---------------------------------------------------------------------
IIS Log:
2018-12-20 02:23:52 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 3
2018-12-20 02:23:54 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 3
2018-12-20 02:23:56 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 4
2018-12-20 02:23:58 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 4
2018-12-20 02:24:00 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 3
2018-12-20 02:24:02 10.239.39.14 GET / - 80 - 10.239.73.215 - - 500 0 64 3

Thanks for you support

Hello,

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.

Respond code is 200, seem it is working now with same configuration I don’t know why it was not working.
Thank you guys