Dynamic Backend server IP

Hello all.
I’m new to HAProxy so still getting used to HA Proxy. With regards to backend configs, I have a scenario where I could have 1000’s backend server configs and wondered if there was a way to dynamically set these in config using a map…

What I’m suggesting is say this:

frontend in
bind 10.0.3.16:5000 accept-proxy
mode tcp
use_backend out
default_backend default

backend out
server int_outbound_ip %[src,map_ip(/etc/haproxy/hosts.map,default)]

This way the IP of the backend server would be dynamically chosen based on the map where I could describe internal to external IP mapping (NAT) ie.

#host.map
#internal IP external IP
172.16.1.1 X.X.1.1
172.16.1.2 X.X.1.2
172.16.1.3 X.X.1.3

1 Like

I am sorry, but I cannot see the business case for this solution. If you need NAT - use NAT - and not HAPROXY.
Where comes any feature of HAPROXY into play?

This would actually be very helpful for me as well… use case is redirecting vmware console.

When the vmware console app request url proxy/ticket/?host= I need to redirect it to the host in the “host” parameter… however our environment is not static, new hosts are added all the time, and removed…

If I could just do:

server int_outbound_ip %[,map_ip(/etc/haproxy/hosts.map,default)] that would be helpful to me.

I’m just starting with ha proxy to work on solution for this issue, but from all I could see ha proxy can configure everything to be dynamic except the actual backend servers, which is a pain. I have also seen API call that can add server to backend, so that might work for me for now…