HAProxy agent-check over http

haproxy

I have to setup haproxy with agent-check, the backend servers reporting themselves their weight ("28%" for example) over http.
Seems like haproxy can't speak http with it's agents, which seems weird. Is there no way to do it ?

I've tried this :

   server X X:80 agent-check agent-port 80 agent-send "GET /some/url HTTP/1.0\r\n" check observe layer7

Which may or may not work, I actually have no idea. Is there any way to tell if the agent-check are succeeding or not ? The statistics page doesn't seem to change whether the url is valid or not. I'm guessing it's not working, because haproxy must be expecting just the value, not any of the http around it.

Best Answer

I agree I don't think it does understand HTTP although I'd be happy to be corrected... Anyone?

UPDATE: I tried this but even if what you request is simply a text file with "ready 88%" it doesn't appear to work... You'd get this back which I guess just confuses it:

HTTP/1.1 200 OK
Date: Sat, 28 Jul 2018 14:22:20 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Sat, 28 Jul 2018 14:14:31 GMT
ETag: "9-5720fd8d9795b"
Accept-Ranges: bytes
Content-Length: 9
Content-Type: text/plain; charset=UTF-8

ready 88%

HTTP compatibility would make a sensible feature request! Maybe something to take to the mailing list. I don't necessarily understand your exact use case but have you considered using a pre-built agent like this one:

https://www.loadbalancer.org/blog/open-source-windows-service-for-reporting-server-load-back-to-haproxy-load-balancer-feedback-agent/

The code is GPL so it could be modified to suit any requirements over and above what it does already.