How to set SMTP config to use localhost? の議論を続けます。
ホストマシンで実行されている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コンテナは「ポートが既に使用されています」というエラーで起動に失敗しました。
最後に、localhostから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))
何が間違っていますか?
このStack Overflowの回答で次のようなものを見つけました。
- ホストサービスにアクセスできるのは、(a)
INADDR_ANY(別名0.0.0.0)でリッスンしているか、明示的に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
ここで、127.0.0.1:1025 でリッスンしているProtonmail Bridgeサービスが、Dockerコンテナからの接続が正確に 127.0.0.1 からではないため、接続を受け付けていないのではないかと疑問に思っていますか?