Send users to the same server for imap and smtp


You want to use Aloha load balancer in front of a mail platform, relying on HAProxy to achieve load-balancing.
You mail platform delivers IMAP acts as a SMTP relay for your users.
You want your users to use the same server for both protocols in order to take advantage of different caches level (FS cache, authentication, etc…)


The HAProxy configuration below explain how to force the SMTP relay for IMAP connected users.
Users relaying mail through SMTP will be connected to any server in the farm using round robin.

frontend ft_smtp
	bind :25
	mode tcp
	default_backend bk_smtp

frontend ft_imap
	bind :143
	mode tcp
	default_backend bk_imap

backend bk_smtp
	mode tcp
	balance roundrobin
	stick match src table bk_imap
	server s1 check
	server s2 check

backend bk_imap
	mode tcp
	# imap connections are usually long
	balance leastconn
	stick store-request src
	stick-table type ip size 200k expire 30m
	server s1 check
	server s2 check


About Baptiste Assmann

Aloha Product Manager HAProxy consultant
This entry was posted in Aloha and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s