# Help setting up imap, pop3, smtp, and web proxy's

**URL:** <https://www.ruby-forum.com/t/help-setting-up-imap-pop3-smtp-and-web-proxys/183198>\
**Category:** NGINX\
**Created:** [February 9, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/help-setting-up-imap-pop3-smtp-and-web-proxys/183198 "2010-02-09T21:30:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ski98033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@ski98033](https://www.ruby-forum.com/u/ski98033)\
**Post date:** [February 9, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/help-setting-up-imap-pop3-smtp-and-web-proxys/183198/1 "2010-02-09T21:30:57Z")

</div>

Hi,

I have searched and was only able to get this partially to work  
(probably because I do not understand the difference between the  
NginxMailProxyModule and NginxMailCoreModule). My goal is to proxy  
webmail, imap, and smtp to different servers based on an ldap lookup. I  
currently have it working for imap and imaps by using Ã˜yvind Kolbu’s  
proxy\_auth perl daemon. My config is at the end of this post. My  
questions are:

1. How do I get smtp proxying to work. The authentication daemon  
returns:

on a smtp connection, but I still get authentication failed. Do I need  
the NginxMailProxyModule? What is the correct config for this?

1. How do I get smtps to work with ssl between the client and nginx?

2. How do I proxy webmail to different servers based on an ldap lookup?

Any examples would be most appreciated.

Thanks in advance,

ski

#nginx.conf  
worker\_processes 1;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;

sendfile on;  
keepalive\_timeout 65;

# http server

server {  
listen 80;  
server\_name [mail.nsd.org](http://mail.nsd.org);

```
location / {
  root /opt/nginx/html;
  index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
  root /opt/nginx/html;
}

```

}

# https server

server {  
listen 443;  
server\_name [mail.nsd.org](http://mail.nsd.org);  
ssl on;  
ssl\_certificate /etc/ssl/private/star\_nsd\_org.crt;  
ssl\_certificate\_key /etc/ssl/private/star\_nsd\_org.key;  
ssl\_session\_timeout 5m;  
ssl\_protocols SSLv2 SSLv3 TLSv1;  
ssl\_ciphers  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
ssl\_prefer\_server\_ciphers on;

```
location / {
  root /opt/nginx/html;
  index index.html index.htm;
}

```

}  
}

mail {  
auth\_http 127.0.0.1:9000;

imap\_capabilities “IMAP4rev1” “UIDPLUS”;

server {  
listen 993;  
server\_name [mail.nsd.org](http://mail.nsd.org);  
ssl on;  
ssl\_certificate /etc/ssl/private/star\_nsd\_org.crt;  
ssl\_certificate\_key /etc/ssl/private/star\_nsd\_org.key;  
ssl\_session\_timeout 5m;  
ssl\_protocols SSLv2 SSLv3 TLSv1;  
ssl\_ciphers  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
ssl\_prefer\_server\_ciphers on;  
protocol imap;  
proxy on;  
}

server {  
listen 25;  
server\_name [mail.nsd.org](http://mail.nsd.org);  
protocol smtp;  
proxy on;  
}  
}

nginx version: nginx/0.7.65  
built by gcc 4.3.2 (Debian 4.3.2-1.1)  
TLS SNI support enabled  
configure arguments: --prefix=/opt/nginx  
–conf-path=/opt/nginx/etc/nginx.conf  
–error-log-path=/opt/nginx/var/log/error.log  
–pid-path=/opt/nginx/var/run/nginx.pid  
–lock-path=/opt/nginx/var/lock/nginx.lock  
–http-log-path=/opt/nginx/var/log/access.log  
–http-client-body-temp-path=/opt/nginx/lib/body  
–http-proxy-temp-path=/opt/nginx/lib/proxy --with-debug  
–with-http\_stub\_status\_module --with-http\_ssl\_module --with-mail  
–with-mail\_ssl\_module --with-http\_perl\_module

Posted at Nginx Forum:

> **[Help setting up imap, pop3, smtp, and web proxy's](https://forum.nginx.org/read.php?2,52788,52788#msg-52788)**
>
> Hi, I have searched and was only able to get this partially to work (probably because I do not understand the difference between the NginxMailProxyModule and NginxMailCoreModule). My goal is to proxy webmail, imap, and smtp to different servers based...

---

<div class="post-metadata">

**Author:** ![ski98033](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@ski98033](https://www.ruby-forum.com/u/ski98033)\
**Post date:** [February 9, 2010, 11:34pm UTC](https://www.ruby-forum.com/t/help-setting-up-imap-pop3-smtp-and-web-proxys/183198/2 "2010-02-09T23:34:29Z")

</div>

Hello!

On Tue, Feb 09, 2010 at 03:30:18PM -0500, ski98033 wrote:

> ```
> 'auth-port' => 25
> 'auth-server' => '10.1.2.50'
> 'auth-status' => 'OK'
> 'client-date' => 'Tue, 09 Feb 2010 19:55:10 GMT'
> 'client-peer' => '10.1.2.49:9000'
> 'client-response-num' => 1
> 
> ```
> 
> on a smtp connection, but I still get authentication failed. Do  
> I need the NginxMailProxyModule? What is the correct config for  
> this?

What’s in error\_log? Most likely the reason is that backend  
rejects mail.

Note well: smtp proxy doesn’t re-authenticate against backend. It  
expects backend which trusts nginx by ip and only passes original  
user’s login via XCLIENT command (if configured to).

> 1. How do I get smtps to work with ssl between the client and  
> nginx?

Either by defining ‘ssl on’ and listen on smtps port (465), or by  
starttls with smtp listen. Or both.

mail {  
…

```
ssl_certificate ...
ssl_certificate_key ...

server {
    listen 25;
    proto smtp;
    starttls;
}

server {
    listen 465;
    proto smtp;
    ssl on;
}

...

```

}

> 1. How do I proxy webmail to different servers based on an ldap  
> lookup?

Most likely you want to set cookie in your login script and then  
select appropriate backend based on it.

Maxim D.
