I’m not quite sure what you are trying to achieve here…
Do you want to load-balance the three mail servers? (I would assume so in the rest of my reply.)
Basically you just need to define a TCP fronted and backend (with three servers), like so:
frontend smtp-frontend
mode tcp
bind ipv4@0.0.0.0:25
bind ipv4@0.0.0.0:587
bind ipv4@0.0.0.0:465 ssl crt /etc/ssl/private/smtp.pem verify none
default_backend smtp-backend
backend smtp-backend
mode tcp
server server-1 ipv4@172.0.0.1:25 maxconn 8 send-proxy check
server server-2 ipv4@172.0.0.2:25 maxconn 8 send-proxy check
server server-3 ipv4@172.0.0.3:25 maxconn 8 send-proxy check
Please note the send-proxy
option to server
, which sends the PROXY
header with the original IP of the client. To make this work in PostFix you need set the following in /etc/postfix/main.cf
:
smtpd_upstream_proxy_protocol = haproxy
proxy_interfaces = 1.2.3.4 # the "public" IP of HAProxy, not sure if this line is actually needed