I want to load balance requests to the same port on three backends. I have about 20 ports to forward, so I need a way to make it dynamic. This is for load balancing our prod, pre-prod, qa, dev, unit test servers for multiple domains. So, yes, I can do it using 20 backends, with 20 acls, and 20 use_backends. But then forget it. Too much hassle.
So, that is, I'd like to use a variable, to mean "the port that was requested". I tried %[dst_port] because that seemed to work in some other situation.
I read one answer somewhere from Willy T, that if one leaves out the port, then it just forwards to the same port.
But it still needs either the service port, or the check port, which I don't know ahead of time, unless I bind to 20 different frontends.
Error: server X has neither service port nor check port nor tcp_check rule
'connect' with port information. Check has been disabled.
eg.
listen load-balance
bind :28080
bind :42080
bind :48080
bind :58080
bind :38080
mode http
balance roundrobin
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost
server X 10.20.30.1 check %[dst_port]
server Y 10.20.30.2 check %[dst_port]
server Z 10.20.30.3 check %[dst_port]
You see, it needs a variable. Is this possible?
(My problem is even more complicated because technically I need a map from destination port to check port, ideally, but if I could do this dynamic port trick, at least, then that's good enough for now.)
Best Answer
You need to configure it with
You can set only one port to check the health or you use the "external-check command" to check your server with a own script...