# Mail proxy config

**URL:** <https://www.ruby-forum.com/t/mail-proxy-config/136417>\
**Category:** NGINX\
**Created:** [May 1, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/mail-proxy-config/136417 "2008-05-01T22:15:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 1, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/mail-proxy-config/136417/1 "2008-05-01T22:15:00Z")

</div>

Hello,

I am having hard times trying to get nginx proxy pop,imap and smtp to  
localhost and remote mail hosts.  
it works fine for the http part but not for mail proxying.

nginx seems to be listening to the standard ports but doesn’t forward to  
the back end server as expected.

The debian package doesn’t include the mail modules , so I compiled from  
th 0.6.29 source.

I think I am missing something in the configuration at the  
authentication stage.

Do I need to configure the module auth somewhere ? it doesn’t exist in  
the source or in the cgi-bin directory.

I also tried to use the php script that is given as an example but I am  
getting errors on the script

PHP Parse error: syntax error, unexpected ‘{’ in /var/www/auth.php on  
line 28.

Removing the unexpected brackets introduce an error at the next line of  
the script

PHP Parse error: syntax error, unexpected ‘;’ in /var/www/auth.php on  
line 37

if anyone can share his experience with the setup of a reverse pop/imap  
proxy I would be delighted.

thanks for your help

M.Dahoumane

my nginx.conf file is below:

user www-data;  
worker\_processes 2;

error\_log /var/log/nginx/error.log;  
pid /var/run/nginx/nginx.pid;

events {  
worker\_connections 512;  
}

mail {

```
auth_http 

```

[http://wiki.codemongers.com/NginxMailAuthModule#auth\_http](http://wiki.codemongers.com/NginxMailAuthModule#auth_http)  
localhost:8000/cgi-bin/auth  
[http://wiki.codemongers.com/NginxMailCoreModule#auth](http://wiki.codemongers.com/NginxMailCoreModule#auth);

```
pop3_capabilities 

```

[http://wiki.codemongers.com/NginxMailCoreModule#pop3\_capabilities](http://wiki.codemongers.com/NginxMailCoreModule#pop3_capabilities)  
“TOP” “USER”;  
imap\_capabilities  
[http://wiki.codemongers.com/NginxMailCoreModule#imap\_capabilities](http://wiki.codemongers.com/NginxMailCoreModule#imap_capabilities)  
“IMAP4rev1” “UIDPLUS”;

```
server <http://wiki.codemongers.com/NginxHttpCoreModule#server> {
    listen <http://wiki.codemongers.com/NginxHttpCoreModule#listen> 

```

110;  
protocol  
[http://wiki.codemongers.com/NginxMailCoreModule#protocol](http://wiki.codemongers.com/NginxMailCoreModule#protocol) pop3;  
proxy [http://wiki.codemongers.com/NginxMailProxyModule#proxy](http://wiki.codemongers.com/NginxMailProxyModule#proxy)  
on;  
}

```
server <http://wiki.codemongers.com/NginxHttpCoreModule#server> {
    listen <http://wiki.codemongers.com/NginxHttpCoreModule#listen> 

```

143;  
protocol  
[http://wiki.codemongers.com/NginxMailCoreModule#protocol](http://wiki.codemongers.com/NginxMailCoreModule#protocol) imap;  
proxy [http://wiki.codemongers.com/NginxMailProxyModule#proxy](http://wiki.codemongers.com/NginxMailProxyModule#proxy)  
on;  
}  
}

http {  
include /etc/nginx/mime.types;  
#default\_type application/octet-stream;  
default\_type text/plain;

```
access_log /var/log/nginx/access.log;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;

gzip on;

include /etc/nginx/sites-enabled/*;

```

## }

/etc/conf default :

server {  
listen 8000;  
server\_name localhost;

```
access_log /var/log/nginx/localhost.access.log;

location / {
    root /var/www/;
    index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /var/www/;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
    proxy_pass http://127.0.0.1;
}

}

deny access to .htaccess files, if Apache's document root
concurs with nginx's one
  location ~ /\.ht {
    deny all;
}

```

}

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 3, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/mail-proxy-config/136417/2 "2008-05-03T19:46:10Z")

</div>

Hello!

On Thu, May 01, 2008 at 10:05:00PM +0200, removed\_email\_address@domain.invalid  
wrote:

[…]

> I think I am missing something in the configuration at the authentication  
> stage.
> 
> Do I need to configure the module auth somewhere ? it doesn’t exist in the  
> source or in the cgi-bin directory.

You have to write authentication script. The first thing nginx  
does is passing authentication requests to auth\_http endpoint. If  
nothing correctly answers at specified url - it won’t be able to  
do anything.

> I also tried to use the php script that is given as an example but I am  
> getting errors on the script

You should either fix errors or write your own script.

[…]

> auth\_http [http://wiki.codemongers.com/NginxMailAuthModule#auth\_http](http://wiki.codemongers.com/NginxMailAuthModule#auth_http) localhost:8000/cgi-bin/auth [http://wiki.codemongers.com/NginxMailCoreModule#auth](http://wiki.codemongers.com/NginxMailCoreModule#auth);
> 
> pop3\_capabilities [http://wiki.codemongers.com/NginxMailCoreModule#pop3\_capabilities](http://wiki.codemongers.com/NginxMailCoreModule#pop3_capabilities) “TOP” “USER”;  
> imap\_capabilities [http://wiki.codemongers.com/NginxMailCoreModule#imap\_capabilities](http://wiki.codemongers.com/NginxMailCoreModule#imap_capabilities) “IMAP4rev1” “UIDPLUS”;

Do you really have all this [http://...](http://...) in your config? You  
shouldn’t.

Maxim D.
