2

I want to setup HA postfix mail servers with 2 postfix instances. I have two postfix servers and I configured two postfix instances on these servers. Now I want to know how to configure HAproxy loadbalancer for the backend postfix servers. Can somebody provide info or useful documentation to configure HAproxy for postfix.

BioLounge
  • 115
  • 1
  • 1
  • 6
  • I have done all other things except HAproxy. I would like to know how to configure HAproxy for postfix. – BioLounge Dec 13 '13 at 20:23
  • No, I mean, what HAproxy configurations have you tried? Have you googled anything about HAProxy and SMTP and made a guess at how a configuration might look? I searched for HAProxy SMTP and got this http://www.linickx.com/645/load-balance-anything-with-haproxy – Tom O'Connor Dec 13 '13 at 20:35
  • 1
    Alternatively, forget about usng haproxy and set up the other server in dns as a backup by entering in another mx record and a lower priority. – hookenz Dec 16 '13 at 21:59
  • SMTP is such a batchy protocol I fail to see why you would need this unless you were expecting hundreds of emails a second. Just setup multiple MX records. – Matthew Ife Dec 17 '13 at 00:25

2 Answers2

3

You will need to run haproxy in tcp mode. Something like this should work:

frontend smtp_in *:25
    mode                tcp
    default_backend     smtp_out

backend smtp_out
    balance leastconn
    server  smtp-server-1.domain.com  smtp-server-1.domain.com:25
    server  smtp-server-2.domain.com  smtp-server-2.domain.com:25
    server  smtp-server-3.domain.com  smtp-server-3.domain.com:25
Dennis Kaarsemaker
  • 19,277
  • 2
  • 44
  • 70
1

Also if you use haproxy 1.5-dev and postfix >= 2.10, you can use the PROXY protocol between the two so that postfix can get the original client's address even through postscreen.

Willy Tarreau
  • 3,896
  • 1
  • 20
  • 12