2

We have a status page that returns either "OK" or "Fail". We set up the tcp-check to look for "OK", which unfortunately doesn't work because it also matches "HTTP/1.1 200 OK" I was thinking I could use rstring with a pattern like .*^OK$. However, this never matches, even though it works when I test the pattern against this response:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/8.5
X-ServerName: myserver
X-AspNet-Version: 4.0.30319
Date: Wed, 20 Mar 2019 16:23:48 GMT
Content-Length: 2

OK

Does tcp-check expect rstring not work the way I think it does? Maybe there is a small detail that I'm missing? Here is what I'm trying in the haproxy config:

This does not work (the probe fails for both OK and Fail responses) (I'm changing server names and IPs, just assume those are valid)

option tcp-check
tcp-check connect
tcp-check send GET\ /status.ashx\ HTTP/1.0\r\n\r\n
tcp-check expect rstring .*^OK$

server myserver1 1.2.3.4:80 check
server myserver2 1.2.3.5:80 check

The following always says both servers are online, whether the probe returns OK or Fail, because of the issue I mentioned earlier with "200 OK":

option tcp-check
tcp-check connect
tcp-check send GET\ /offline.txt\ HTTP/1.0\r\n\r\n
tcp-check expect string 404 - File or directory not found.

tcp-check connect
tcp-check send GET\ /status.ashx\ HTTP/1.0\r\n\r\n
tcp-check expect rstring OK

server myserver1 1.2.3.4:80 check
server myserver2 1.2.3.5:80 check

So plain "OK" works with rstring, but when I try to apply a pattern it doesn't work the way I expect.

PlantationGator
  • 139
  • 1
  • 6

1 Answers1

1

After more testing and trial and error I figured out the discrepancy that I was seeing was due to the multiline regex option. Without the multiline option set, my pattern doesn't work. So HAProxy must not use this option. Incidentally, in this case the pattern OK$ works because it interprets this to mean that the entire string ends with OK. If there is a Fail returned, the earlier line ending with OK doesn't match, so the probe works as expected.

PlantationGator
  • 139
  • 1
  • 6