HAProxy community

Haproxy as gateway

Hello guys,
I configured Postfix via Haproxy(Centos), everything works great, but I have one problem.
When my backend server needs to send its mails(not for request, but when it initializes connection) to an another mail server, it must use own gateway,
but I need to forward everything by Haproxy server. Is it possible to forward via HAproxy to the Internet? I need to haproxy works like gateway.
I tried with iptables(iptables -t nat -A POSTROUTING -d -o enp0s3 -j SNAT --to-source, but it didnt work.

Like on the picture

Could you help me?


this is hardly a haproxy issue. Please don’t tell us things “didn’t work”, it really brings no value to the troubleshooting. Instead, describe how things don’t work. Looking at packet captures and telling us where you see packets and where you don’t when you expect them would be more helpful.

You have configured snat, but did you enable ip forwarding?

You may want to read this link, to make use of the PROXY protocol.
PROXY protocol reduce your use of iptables rules.

Hope it could help.