Hello Stephan,
On Fri, Nov 04, 2016 at 04:24:02PM +0100, Stephan Müller wrote:
> Hello,
>
> i have a TCP backend with two servers. I want to check both, but with
> different checks, like below:
>
> backend foo
> mode tcp
> server srv1 192.168.0.1 check # <-- do a TCP check
> server srv2 192.168.0.2 check backup # <-- do a HTTP check
>
> I could imagine something like:
>
> frontend foo
> ...
> use_backend foo:srv1 if { srv_is_up(be:srv1/srv1) }
> use_backend foo:srv2 if { srv_is_up(be:srv2/srv2) }
> ...
>
> backend be:srv1
> mode tcp
> server srv1 192.168.0.1 check
>
> backend be:srv2
> mode tcp
> option httpchk GET /health HTTP/1.0\r\n
> server srv2 192.168.0.2 check
>
> but it would be nice to find a clean and direct way. Any ideas are welcome.
The health-check method is per-backend so indeed you can't have a per-server
check method. However a server can track another one instead of being checked,
which means you can do that :
backend foo
server srv1 192.168.0.1 track be1/srv
server srv2 192.168.0.2 track be2/srv backup
backend be1
server srv 192.168.0.1 check
backend be2
option httpchk GET /health HTTP/1.0\r\n
server srv 192.168.0.2 check
This generally is the cleanest way to do it and it doesn't add too much
complexity considering the added flexibility.
Regards,
Willy