I would like to use HAProxy to forward an inbound request to two servers, an old one and a new one, depending on which one is up and running, or randomly if both of them are up.
If the request hits the new server I also need a request rewrite with a special path (hence the http-request below):
frontend myservice
bind:1111
use_backend back-a
use_backend back-b
backend back-a
server back-0 hostname_old:2222 check
backend back-b
http-request set-path /special-path/%[path]
server back-1 hostname_new:443 check-ssl ssl verify none
The above does not work. The request is always forwarded to whichever backend is listed first: and if that’s not available I get an error.
Any suggestions?
All the examples I’ve seen of use_backend are followed by an “if”, but I don’t need any special condition, could that be the issue?
Many thanks!