Utilising healthcheck endpoint running on the same machine as HAProxy?

Hey everyone,

TL;DR: Is it possible to make use of a /health endpoint that is running locally on the HAProxy box, when doing health checks for a back-end? I know that we can specify a health-checking endpoint running on the remote server, e.g.:

backend myserver
option httpchk
http-check send meth GET uri /health
http-check expect status 200
http-check expect string GOOD

But, would it be possible to use a /health endpoint that is not running on that backend server in the health evaluation process, but instead locally (or somewhere completely different)? i.e.:

backend myserver
option httpchk
http-check send meth GET uri **localhost:8001**/health
http-check expect status 200
http-check expect string GOOD

I wrote a pretty involved health-checker that I meant to have running on each HAProxy box, that itself would continuously monitor, and steer backend-resources, under the assumption that I could make use of a /health endpoint elsewhere than running on the backend in question. I would prefer not to do a whole redesign and run the services on the backends themselves, so I’d greatly appreciate any and all input here.

Cheers

In this case I suggest you switch from regular health checks to agent-checks.

https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#5.2-agent-check

Interesting, I wasn’t aware of this functionality. Are agent-checks available with standard HAProxy, too, or HAPEE only?

Furthermore, do agent-checks exclude regular health-checks - i.e., can I use both an agent-check, and a standard health checker (expecting 200, status GOOD e.g.)?

I am actually using HAProxy as more of a failover machine, rather than a load-balancer. I want to switch backends depending on some logic that I’m performing on the same machine, and hence my problem here.

Thank you!

Opensource Haproxy. I don’t know anything about HAPEE.

You can do both or only agent-checks, whatever you prefer. I suggest you read the documentation that I linked above.