2012-10-24 13 views
1

我需要使用nginx作为邮件代理。我对nginx完全陌生,需要一些配置帮助。无法将nginx配置为邮件代理

这里是我做过什么:

首先我建立了一个嘲笑这里所描述的身份验证服务的服务:http://wiki.nginx.org/NginxMailCoreModule。例如,

curl -v -H "Host:auth.server.hostname" -H "Auth-Method:plain" -H "Auth-User:user" -H "Auth-pass:123" -H "Auth-Protocol:imap" -H "Auth-Login-Attempt:1" -H "Client-IP: 192.168.1.1" http://localhost:8080/authorize 

返回以下响应头:

< HTTP/1.1 200 OK 
< Content-Type: text/html;charset=ISO-8859-1 
< Auth-Status: OK 
< Auth-Server: 192.168.1.10 
< Auth-Port: 110 

我在我的Mac安装nginx的安装使用MacPorts后:

$ sudo port -d selfupdate 
$ sudo port install nginx 

我创建了一个nginx的.conf与以下内容:

worker_processes 1; 

    error_log /var/log/nginx/error.log info; 

    mail { 
     server_name <my mail server here>; 
     auth_http http://localhost:8080/authorize; 

     pop3_auth   plain apop cram-md5; 
     pop3_capabilities "LAST" "TOP" "USER" "PIPELINING" "UIDL"; 

     xclient off; 

     server { 
      listen  110; 
      protocol pop3; 
      proxy  on; 
      proxy_pass_error_message on; 
     } 
    } 

这是我跑了nginx的:

$ nginx的-V nginx的版本:nginx的/ 1.2.4 配置参数:--prefix = /选择/本地--with-CC- opt =' - I/opt/local/include -O2'--with-ld-opt = -L/opt/local/lib --conf-path =/opt/local/etc/nginx/nginx.conf - error-log-path =/opt/local/var/log/nginx/error.log --http-log-path =/opt/local/var/log/nginx/access.log --pid-path =/opt /local/var/run/nginx/nginx.pid --lock-path =/opt/local/var/run/nginx/nginx.lock --http-client-body-temp-path =/opt/local/var/run/nginx/client_body_temp --http-proxy-temp-path =/opt/local/var/run/nginx/proxy_temp --http -fastcgi-temp-path =/opt/local/var/run/nginx/fastcgi_临时--http-uwsgi-TEMP-PATH = /选择/本地的/ var /运行/ nginx的/ uwsgi_temp --with的IPv6

$ nginx的 nginx的:在/ opt [EMERG]未知的指令 “邮件”/本地/etc/nginx/nginx.conf:6

在网络上是错误的,只有提起带来了在俄罗斯的讨论......

我的问题:

  1. 为什么我收到这个unknow指令?

  2. 我的配置一看就是正确的,还是我错过了一些使用此处所述的身份验证方法工作的邮件代理的关键组件:http://wiki.nginx.org/NginxMailCoreModule

+0

当我的SMTP服务器只发送电子邮件时,需要让nginx参与吗? –

回答

4

我的邮件代理工作,所以我会回答我自己供将来参考的问题:

  1. nginx的默认不

    安装邮件支持需要对以下nginx处理邮件指令:

    $ sudo port编辑nginx

    ==>加上--with-邮件在配置参数的端

    然后(重新)安装nginx的

  2. 在我包括配置,我是缺少的事件:

    事件{
    worker_connections 1024;
    }

  3. 这让我停留了一段时间的重要说明:身份验证服务(与auth_http指定)需要返回表示为一个IP地址,而不是主机名的邮件服务器。

  4. 很显然,对于入站和出站流量的nginx代理,需要添加smtp监听器。与pop3配置类似的方法。在我的情况下,我使用端口2525,所以我有

    服务器{
    listen 2525;
    协议smtp;
    }