lf215
lf215

Reputation: 1009

haproxy return empty response

I'd like to have health checks to an haproxy instance fail solely based on whether haproxy is running. In other words I don't want the health check to be proxied to a backend server.

I see there is a way to do this by returning a static file. This would work for me, but I was wondering: Is there a way to return an empty response with just a status code without having to return a file and deal with the false 503? The solution linked seems hacky and I worry that behavior will not be allowed in some later version.

Upvotes: 3

Views: 2507

Answers (1)

nuster cache server
nuster cache server

Reputation: 1791

monitor-uri <uri>

Intercept a URI used by external components' monitor requests
May be used in sections :

When an HTTP request referencing will be received on a frontend, HAProxy will not forward it nor log it, but instead will return either "HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure conditions defined with "monitor fail". This is normally enough for any front-end HTTP probe to detect that the service is UP and running without forwarding the request to a backend server. Note that the HTTP method, the version and all headers are ignored, but the request must at least be valid at the HTTP level. This keyword may only be used with an HTTP-mode frontend.

Example :

# Use /haproxy_test to report haproxy's status
frontend www
    mode http
    monitor-uri /haproxy_test

Upvotes: 3

Related Questions