大网数据广告活动
服务器运维问答

How to setting postfix with nginx reverse proxy

· 52CE 我爱测

i want to make a mail server. But i want my mail server not directly connect to internet. So i make another server that accessible via internet and using reverse proxy with nginx. But for some reason reverse proxy cannot connect …

问题原文

原帖链接 · Ilham Sulaksono · CC BY-SA 3.0

i want to make a mail server. But i want my mail server not directly connect to internet. So i make another server that accessible via internet and using reverse proxy with nginx. But for some reason reverse proxy cannot connect to mail server. Here is my 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;
        }
}

Here is my error log

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

I already check https://www.nginx.com/resources/admin-guide/mail-proxy/. But i want redirect sent mail to my mail server

update

[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

already commenting the inet_interface and still the same

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1032/master
tcp6       0      0 ::1:25                  :::*                    LISTEN      1032/master

已采纳解答

原帖链接 · Gerald Schneider · CC BY-SA 3.0

Your postfix only listens on the localhost interface, it does not accept connections from other machines. Configure it to listen on 0.0.0.0:

Comment out that line in /etc/postfix/main.cf by adding a # in front.

#inet_interfaces = 127.0.0.1

Or change the address to 0.0.0.0. Restart postfix afterwards.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。