Imap proxy?

Can someone give me an example of how to do an IMAP and POP3 proxy in
nginx. What i need to do is send all requests for domain1.com to one
server and all requests for domain2.com to another. I have read the
examples on the wiki but I do not understand them. I have a working
HTTP and HTTPS install now and would like to further secure my servers.
Any help would be appreciated

Brian.

On Sat, Aug 22, 2009 at 3:40 AM, Brian Henson[email protected]
wrote:

Hi,

I don’t think that the IMAP protocol has something like the “Host”
header in HTTP. In other words, the proxy cannot figure out which
domain the user is trying to access. So you have to bind two different
proxies on two separate IP addresses.

Georgi H. wrote:

Georgi,

I know you can separate it by the letter it starts with. (fastmail

does this) If there was a host header or some variation there of it
would be nice. can i get a definite answer from someone who has used
the imap proxy please? the docs are incomplete on the features.

thanks

brian

±-----------------------------------------------------------------------------
| On 2009-08-22 01:36:06, Brian Henson wrote:
|

I know you can separate it by the letter it starts with. (fastmail
does this) If there was a host header or some variation there of it
would be nice. can i get a definite answer from someone who has used
the imap proxy please? the docs are incomplete on the features.

The nginx IMAP proxy can speak to a CGI to do IMAP authentication
munging.

The CGI does whatever user lookups you need. The auth script then
returns to
nginx the username, hostname, port, etc, to nginx which hands that off
to the
IMAP server you specify for authentication.

At work we use a Catalyst server for this:

  • Client hits nginx
  • nginx hits auth_server.pl
  • auth_server.pl uses the passed-in username to look up the user’s
    IMAP/POP
    server:port, and their internal account ID (which is what Cyrus uses
    for
    authentication)
  • auth_server.pl passes the above back to nginx
  • nginx proxies the connection to the user’s IMAP/POP server:port,
    using the
    new acctid@domain credentials

The example on the nginx wiki seems to be pretty clear, using a simple
PHP
script:

http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript

We’ve been using this for a bit over two years, without issue. nginx is
pretty
great, and the IMAP/POP proxying works very well.