HAProxy community

Set frontend_ip as source IP for backend


I have a server with multiple IP configured on it ( as virtual IP on eth0). I’m using Haproxy for Load balacing. Each IP has been configured/pointed to different domain name and All requests that comes to each IP address is being forwarded to different backend server by using haproxy.

Issue here, all outgoing traffic from haproxy is pass through main interface IP[eth0] [ by default]. I just wanted to set source ip for backend connection.

I tried the below config, its not working. Any idea ?

backend web1
server ss2 source ${frontend_ip}

frontend new1
mode tcp
use_backend web1


Not going to work unless you either use X-Forward or the HAProxy server is the gateway.


Why not just:

backend  web1
       server ss2 source


Given solution is working.