Expected Status or String
Change the expected HTTP success status
Use http-check expect
to specify the HTTP status code indicating a healthy server. In the following example, the server must return a 200 OK response:
backend bk_myapp
option httpchk
http-check expect status 200
server srv1 10.0.0.1:80 check
server srv2 10.0.0.2:80 check
As an alternative to http-check expect status
, where you specify one explicit status value, you can use rstatus
to specify a regular expression to match multiple status codes. In the next example, the health check uses rstatus
in conjunction with the negation operator (!) to consider all statuses as valid except for 5xx responses:
backend bk_myapp
option httpchk
http-check expect ! rstatus ^5
default-server inter 3s fall 3 rise 2
server srv1 10.0.0.1:80 check
server srv2 10.0.0.2:80 check
Setting an expect string in HTTP and TCP checks
You can specify a string to search for in the body of an HTTP or TCP response.
To specify the string that you expect to see in the body, add the expect string
directive to http-check
or tcp-check
.
In the next example, the response must contain the string "OK".
The response must contain the string OK.
backend be_myapp
option httpchk
http-check expect string OK
server srv1 10.0.0.1:80 check
server srv2 10.0.0.2:8080 check
Use the expect rstring
argument to specify a regular expression instead of an explicit string.
For the complete list of parameters that can be specified on the expect
line, see http-check expect.
Next up
Logging Comments on Failure