Search code examples
nginxproxyimapwebmail

IMAP Proxy that can connect to multiple IMAP servers


What I am trying to achieve is to have a central Webmail client that I can use in a ISP envioroment but has the capability to connect to multiple mail servers.

I have now been looking at Perdition, NGINX and Dovecot. But most of the articles have not been updated for a very long time.

The one that I am realy looking at is NGINX imap proxy as it can almost do everything i require. http://wiki.nginx.org/ImapAuthenticateWithEmbeddedPerlScript

But firstly the issue I have is you can no longer compile NGINX from source with those flags. And secondly the GitRepo for this project https://github.com/falcacibar/nginx_auth_imap_perl

Does not give detailed information about the updated project.

So all I am trying to achieve is to have one webmail server that can connect to any one of my mailservers where my location is residing in a database. But the location is a hostname and not a IP.


Solution

  • You can tell Nginx to do auth_http with any http URL you set up. You don't need an embedded perl script specifically.

    See http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html to get an idea of the header based protocol Nginx uses.

    You can implement the protocol described above in any language - CGI script with apache if you like. You do the auth and database query and return the appropriate backend servers in this script.

    (Personally, I use a python + WSGI server setup.)

    Say you set up your script on apache at http://localhost:9000/cgi-bin/nginx_auth.py

    In your Nginx config, you use:

    auth_http http://localhost:9000/cgi-bin/nginx_auth.py