我想制作一个邮件服务器。 但是,我想我的邮件服务器不直接连接到互联网。 所以我让另一台服务器可以通过互联网访问,并使用反向代理与Nginx。 但由于某些原因,反向代理无法连接到邮件服务器。 这是我的nginx conf:
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } stream { log_format proxy '$remote_addr [$time_local] ' '$protocol $status $bytes_sent $bytes_received ' '$session_time "$upstream_addr" ' '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'; access_log /var/log/nginx/access.stream.log proxy; server { listen 25; #protocol smtp; proxy_pass 10.0.1.15:25; } server { listen 110; #protocol pop3; proxy_pass 10.0.1.15:110; } server { listen 143; #protocol imap; proxy_pass 10.0.1.15:143; } }
这是我的错误日志
2017/09/08 09:02:56 [error] 1444#1444: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 54.240.25.13, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:06:38 [error] 1444#1444: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 209.85.128.182, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:07:57 [error] 1444#1444: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 54.240.25.4, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:16:10 [notice] 1951#1951: signal process started 2017/09/08 09:16:42 [error] 1952#1952: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 74.125.82.46, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:19:39 [error] 1952#1952: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 54.240.25.8, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:22:51 [error] 1952#1952: *5 connect() failed (111: Connection refused) while connecting to upstream, client: 74.125.82.50, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:26:10 [emerg] 9086#9086: unknown log format "main" in /etc/nginx/nginx.conf:19 2017/09/08 09:27:09 [notice] 9090#9090: signal process started 2017/09/08 09:27:53 [error] 9091#9091: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 209.85.128.176, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0 2017/09/08 09:28:37 [error] 9091#9091: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 209.85.128.170, server: 0.0.0.0:25, upstream: "10.0.1.15:25", bytes from/to client:0/0, bytes from/to upstream:0/0
我已经检查https://www.nginx.com/resources/admin-guide/mail-proxy/ 。 但我想redirect发送邮件到我的邮件服务器
更新
[ec2-user@ip-10-0-1-15 ~]$ sudo netstat -nlp | grep :25 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1032/master tcp6 0 0 ::1:25 :::* LISTEN 1032/master
已经评论了inet_interface,仍然是一样的
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1032/master tcp6 0 0 ::1:25 :::* LISTEN 1032/master
你的后缀只能监听本地主机接口,它不接受来自其他机器的连接。 将其configuration为在0.0.0.0上进行侦听:
在/etc/postfix/main.cf通过在前面添加一个#注释掉该行。
#inet_interfaces = 127.0.0.1
或将地址更改为0.0.0.0 。 之后重新启动postfix。
除了Gerald的回答之外,您还在您的server {}部分中注释了所有protocol指令。 他们是必需的,以确定正确的协议。
我希望你已经在使用NGINX作为邮件代理服务器了 。
至less增加starttls on; 和一切有关将是一个好主意…