Docker Mailcow:使用SMTP,POP3和IMAP作为Docker容器映像的Mail反向代理的Nginx

在我的服务器上,我在debian服务器上运行了一个mailcow:dockerized解决scheme,我想用nginx作为一个http反向代理,而且也用作一个SMTP imappop3,如https://www.nginx.com /资源/pipe理引导/邮件代理/

但是,我进一步阅读链接时,很难弄清楚这将如何完成。 在http中,显而易见的是这将如何完成:

server { listen 80; server_name mail.example.tk; location /.well-known { proxy_pass http://127.0.0.1:8080/.well-known ; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 100m; } location / { rewrite ^(.*) https://$server_name$1 permanent; } } server { listen 443 ssl; server_name mail.example.tk; ssl_certificate /opt/docker-mailcow/data/assets/ssl/cert.pem; ssl_certificate_key /opt/docker-mailcow/data/assets/ssl/key.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location / { proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 100m; } } 

但是使用smtp,pop3和imap这个怎么做呢? 请继续关注docker映像运行在与nginx相同的服务器上,它们是:

 827c20cee898 mailcow/dovecot:1.0 "/docker-entrypoin..." 50 minutes ago Up 50 minutes 24/tcp, 10001/tcp, 0.0.0.0:2110->110/tcp, 0. 76a977a8064e mailcow/postfix:1.0 "/bin/sh -c 'exec ..." 50 minutes ago Up 50 minutes 588/tcp, 0.0.0.0:2525->25/tcp, 0.0.0.0:2465- 

有任何想法吗?

根据评论,这听起来像是在邮件代理的HTTPauthentication服务器周围的问题。 该指南的位谈到这一点:

来自客户端的每个POP3 / IMAP / SMTP请求将首先通过外部HTTPauthentication服务器或通过authentication脚本进行authentication。 NGINX邮件服务器代理必须具有authentication服务器。 服务器可以根据基于HTTP协议的NGINXauthentication协议自行创build。

它链接到http://nginx.org/en/docs/mail/ngx_mail_auth_http_module.html#protocol ,进一步进入请求和响应应该看起来像什么。 它给出了这个请求的例子:

 GET /auth HTTP/1.0 Host: localhost Auth-Method: plain # plain/apop/cram-md5/external 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 

这是你的auth_http服务器将会收到的。 然后,你的auth_http服务器将需要响应类似于:

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

来自服务器的响应包含请求将被代理到的服务器IP和端口。

不幸的是,他们没有给出任何示例HTTP服务器或代码来运行。 不过,我在https://www.nginx.com/resources/wiki/start/topics/examples/imapauthenticatewithapachephpscript/find了另一篇文章,以PHP服务器脚本为例。