SMTP配置使用localhost或172.17.0.1不工作,如何调试

继续讨论 如何设置 SMTP 配置以使用本地主机?

我正在尝试连接到运行在主机上的 Protonmail Bridge,但连接被拒绝。我的设置是:

  DISCOURSE_SMTP_ADDRESS: 172.17.0.1
  DISCOURSE_SMTP_PORT: 1025

现在,进行 nmap 测试:

主机上的 nmap 127.0.0.1 输出:

Nmap scan report for localhost (127.0.0.1)
Host is up (0.000010s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
1025/tcp open  NFS-or-IIS
1042/tcp open  afrog

Docker 容器中的 nmap 172.17.0.1 没有输出 1025 端口。

我也在 app.yml 文件的 expose 部分尝试过:

172.17.0.1:1025:1025

但随后 Docker 容器启动失败,并报错“端口已被占用”。

最后,如果我尝试从本地主机使用 openssl 连接:

openssl s_client -connect 127.0.01:1025 -starttls smtp

这工作正常;但当尝试从 Docker 容器连接时,则不行:

openssl s_client -connect 172.17.0.1:1025 -starttls smtp

在主机上使用 ss 检查:

ss -plnt
State  Recv-Q  Send-Q  Local Address:Port  Peer Address:Port  Process
LISTEN   0      4096       127.0.0.1:1025      0.0.0.0:*    users:(("proton-bridge",pid=953,fd=12))

我哪里做错了?


我在 这个 stackoverflow 回答 中发现了一点:

  • 您只能访问以下主机服务:(a) 正在监听 INADDR_ANY(即 0.0.0.0)的服务,或者 (b) 明确监听 docker0 接口的服务。

首先,我检查了 iptables --list,我认为这会给出默认输出:

iptables --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy DROP)
target     prot opt source               destination
DOCKER-USER  all  --  anywhere             anywhere
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain DOCKER (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:https
ACCEPT     tcp  --  anywhere             172.17.0.2           tcp dpt:http

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere
RETURN     all  --  anywhere             anywhere

Chain DOCKER-USER (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

现在,我想知道 Protonmail Bridge 服务是否正在监听 127.0.0.1:1025,但它不接受来自 Docker 容器的连接,因为它们不完全来自 127.0.0.1

流量需要重定向,请在此处阅读更多信息:

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.