Using map file in backend config / dynamic backends?

Hi all

I think that what I want to do can’t be done but I might as well throw it out there to check.

I’ve a hosted solution were multiple customers connect to customer specific URLs and get redirected to unique backends. These backends connect to a Docker swarm where the connection is identical for each customer except for the port they connect to (dedicated interface servers running in Docker)

So for example

frontend fe-frontdoor
blah blah blah…
use_backend dockerSwarmPort1000 if { hdr(host) -i customerjohn.myservice.com }
use_backend dockerSwarmPort1001 if { hdr(host) -i customerpaul.myservice.com }
use_backend dockerSwarmPort1002 if { hdr(host) -i customerringo.myservice.com }

backend dockerSwarmPort1000
server docker01 192.168.1.1:1000
server docker02 192.168.1.2:1000
server docker03 192.168.1.3:1000

backend dockerSwarmPort1001
server docker01 192.168.1.1:1001
server docker02 192.168.1.2:1001
server docker03 192.168.1.3:1001

I appreciate I can use map files for the front end but is it possible to do the same or similar with the backend to save me having to create hundreds of practically identical backends.

I’m assuming not as you’d need to pass some sort of parameter to the generic backend and I’m not aware of HAProxy supporting this?

Any alternative approaches also welcome.

Thanks

Try using http-request set-dst-port and a map statement as expression.

Thanks Lukas, that looks like it’ll do exactly what I need