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.