mail proxy config

mdl2 at mdl2 at
Fri May 2 00:05:00 MSD 2008


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


my nginx.conf file is below:

user www-data;
worker_processes  2;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx/;

events {
    worker_connections  512;

mail {

    auth_http <>  localhost:8000/cgi-bin/auth <>;

    pop3_capabilities <>  "TOP"  "USER";
    imap_capabilities <>  "IMAP4rev1"  "UIDPLUS";
    server <> {
        listen <>     110;
        protocol <>   pop3;
        proxy <>      on;

    server <> {
        listen <>     143;
        protocol <>   imap;
        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
    location ~ \.php$ {


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

More information about the nginx mailing list