Date created: 05/03/13 15:30:34. Last modified: 05/03/13 15:30:34

Monitor URI with Backend ACL

Here the frontend ACL backend_down will be true if less than two backend servers are considered "UP" by HAProxy. 

Accessing the monitor URI from a host outside the monitor-net subnet will return HTTP 200 OK. When the ACL evaluates to true (when less than 2 back end servers are up) the monitor fail action will take over, and a HTTP 503 error will be returned. For the host that is inside the monitor-net subnet, they will always receive the HTTP 200 OK response, simply to indicate that HAProxy is running, irelivant of the backend status.

In the docs, "In HTTP mode, a connection coming from a source matching <source> will be accepted, the following response will be sent without waiting for a request, then the connection will be closed : "HTTP/1.0 200 OK". 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.https://code.google.com/p/haproxy-docs/wiki/monitor_net

 

frontend monitor-http-servers
	bind 192.0.2.1:80

        acl backend_down nbsrv(http-servers) lt 2

        monitor-uri /mymonitoruri
        monitor-net 192.0.2.10/32
        monitor fail if backend_down

	default_backend http-iis-servers

backend http-servers

        cookie server insert
        option persist
        option redispatch
        server  server1 192.168.0.1:80 cookie s1 check inter 2000 rise 3 fall 3
        server  server2 192.168.0.2:80 cookie s2 check inter 2000 rise 3 fall 3

Previous page: HAProxy
Next page: keepalived