您的位置:首页 > 运维架构 > Nginx

nginx做mail proxy 的时候,把消息proxy到哪里去了 4000

2015-11-28 23:10 651 查看
最近研究nginx代码, 以mail模块入手, 但是从配置看, 一直看不出来nginx把消息proxy到哪里去了.

今天研究了半天, 才搞这个事情搞清楚. 之前在网上也没有找到类似的说明, 包括官方的文档也没有说明.

mail模块有一个
ngx_mail_auth_http_module.c
模块, 其中有一个配置命令
auth_http
,nginx通过向此配置发送一个http请求,以获取得后端mail server的ip和端口. 比如:

Request:

GET /auth HTTP/1.0
Host: localhost
Auth-Method: plain # plain/apop/cram-md5
Auth-User: user
Auth-Pass: password
Auth-Protocol: imap # imap/pop3/smtp
Auth-Login-Attempt: 1
Client-IP: 192.0.2.42
Client-Host: client.example.org

Good response:

HTTP/1.0 200 OK
Auth-Status: OK
Auth-Server: 198.51.100.1
Auth-Port: 143

以上的
Request
是nginx发送给
auth_http
配置的url的请求,
Good response
是相应响应.
nginx从这个响应中的
Auth-Server
Auth-Port
获取得到后端mail server的ip和端口.
nginx会连接到这个ip:port,并与此按相就的邮件协议(如POP3)交互.

同时

If the “Auth-User” header exists in the response, it overrides the username used to authenticate with the backend.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx mail