7

is it possible to check two conditions on one backend? example

backend web-static
        option httpchk GET /path/alive.php HTTP/1.1\r\nHost:\ www1.domain.com
        option httpchk GET /path2/alive.php HTTP/1.1\r\nHost:\ www1.domain.com
        server appsrv1 192.168.1.10:80 check inter 3000 weight 1

2 Answers 2

2

Probably, it'd be easier to make a "wrapper" PHP: it checks the other files, and if everything is ok, it returns with HTTP code 200, if not, 404.

As I remember, this worked for us too when we wanted functionality check too.

1
  • nice tip i will try it out!
    – Elgreco08
    Mar 31, 2011 at 12:28
8

Ah, I had the same question! Our developers produced a multi-function Web service off one URL name, because we need to support non-CORS-compliant browsers (IE 8 and 9). One DNS name leading to one VIP address has several subdirectories, each a different application. So our load balancer has to health-check each one of the services, and then treat it as a big "AND" test, i.e., if even one of the services doesn't pass the check, then we must yank that server out of the farm until all of them pass.

We're transitioning over from Cisco ACE load balancers, and on that platform, you simply define multiple "probe" configs and then call for multiple probes within a single server farm, one line after another, and it runs all the probes. As you probably discovered, HAProxy doesn't let you define more than one "option httpchk"... or at least it ignores all but one of them, so you don't get the testing you're after. But I figured out from the manual that I could do it by not using httpchk, substituting a series of "connect, send, check" lines under "option tcp-check". It works perfectly.

option tcp-check
tcp-check connect
tcp-check send GET\ /FirstApplication/check.aspx?healthcheck\ HTTP/1.0\r\n\r\n
tcp-check expect string Healthy
tcp-check connect
tcp-check send GET\ /SecondApplication/check.aspx\ HTTP/1.0\r\n\r\n
tcp-check expect string YesThisIsGood
tcp-check connect
tcp-check send GET\ /ThirdApp/Check.aspx\ HTTP/1.0\r\n\r\n
tcp-check expect string ExpectedCheckResult
tcp-check connect
tcp-check send GET\ /NumberFourApp/check.aspx\ HTTP/1.0\r\n\r\n
tcp-check expect string YesItIsWorking

Note that you have to backslash-escape each space in the string you're sending. I'm using HTTP/1.0 in the request, which by default doesn't do keepalive, so I'm reconnecting in each series of lines. I suppose I could also use HTTP/1.1, but then I'd also have to transmit a Host header, so I think it's easier this way. Running these four checks in a row, it still takes only 60ms, so I'm satisfied. Also note that I'm just using "expect string", but there's also an "expect rstring" for regular expression searching through the result content coming back from the server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .