# Building a redundant mail service

**URL:** <https://www.ruby-forum.com/t/building-a-redundant-mail-service/232108>\
**Category:** NGINX\
**Created:** [September 18, 2014, 2:03pm UTC](https://www.ruby-forum.com/t/building-a-redundant-mail-service/232108 "2014-09-18T14:03:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 18, 2014, 2:03pm UTC](https://www.ruby-forum.com/t/building-a-redundant-mail-service/232108/1 "2014-09-18T14:03:33Z")

</div>

Hello,

I would appreciate your advice on the following:

We are trying to build a redundant mail service, and we are  
investigating the use of nginx as smtp/pop3/imap proxy with TLS/SSL  
support (ports 25/587, 143/993, 110/995).

We already have two production mail servers, vmail1 and vmail2, running  
postfix/dovecot (with virtual users on LDAP), each running on a separate  
data center.

vmail1 is the main one (i.e. the one used to send mail and host users’  
mailboxes), vmail2 is only used as a backup.

Mailboxes are using Maildir format and are being synced (in near  
real-time) using dovecot dsync service.

IMPORTANT: Each of the two servers has its own distinct server name and  
its own separate certificate. This allows proper parallel operation of  
postfix and dovecot IMAP syncing.

(I will not describe the incoming mail process, because it is beyond the  
scope of this mail.)

Our goal is to allow our users to always use one address, say  
_[vmail.example.com](http://vmail.example.com)_, to automatically access SMTP/POP3/IMAP services at  
vmail1 and, only if vmail1 is down, at vmail2.

DNS could offer a solution: creating, for example, a CNAME  
“[vmail.example.com](http://vmail.example.com)” pointing to vmail1 would probably solve the problem  
by using a very low DNS record refresh time and use a script to monitor  
vmail1 availability; if vmail1 is down, the script could update the  
CNAME to point to vmail2 instead (and force a zone refresh). This could  
leave a small downtime window (depending on the refresh time  
configured).

Yet, I am thinking that it may be more advantageous to use another two  
_identical_ VMs (one on each data center, for redundancy) running NGINX,  
with the common name (and a common certificate for) [vmail.example.com](http://vmail.example.com)  
(in DNS: an A record with two IP Addresses). Both proxies would  
automatically redirect (via NGINX) all SMTP/POP3/IMAP requests to vmail1  
and, only if vmail1 is down, to vmail2, while the user will always  
see/configure [vmail.example.com](http://vmail.example.com) as their mail server.

Is this a feasible scenario? Any hints, experiences, configuration  
advice, pitfalls, alternative approaches etc. would be greatly  
appreciated.

Please advise.

Thanks in advance,  
Nick

---

<div class="post-metadata">

**Author:** ![Nikolaos\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecc23a/32.png) [@Nikolaos\_M](https://www.ruby-forum.com/u/Nikolaos_M)\
**Post date:** [December 17, 2015, 10:55am UTC](https://www.ruby-forum.com/t/building-a-redundant-mail-service/232108/2 "2015-12-17T10:55:54Z")

</div>

Hi Nick,

have you ever figured this out?

If so, would it be possible to post your solution?

Thanks,  
Cugar15

Posted at Nginx Forum:

> **[Re: Building a redundant mail service](https://forum.nginx.org/read.php?2,253381,263498#msg-263498)**
>
> Hello, I would appreciate your advice on the following: We are trying to build a redundant mail service, and we are investigating the use of nginx as smtp/pop3/imap proxy with TLS/SSL support (ports 25/587, 143/993, 110/995). We already have two p
