Problem: a) Protonmail Bridge cannot listen to IP other than 127.0.0.1
, and b) Discourse in a Docker container cannot send SMTP requests to 127.0.0.1
of the host machine.
Solution: We configure it to send to 172.17.0.1
(the Docker’s bridge IP on the host machine), and then redirect to 127.0.0.1
, on which the Protonmail Bridge is listening.
We do it with using Socat.
How To
Start by installing Socat:
apt install socat
We will run Socat as a service. Create service file:
nano /etc/systemd/system/protonsocat.service
… and put the following content in it:
[Unit]
Description=Socat Bridge ProtonMail/Discourse
After=protonbridge.service,docker.service
ReloadPropagatedFrom=docker.service
[Service]
ExecStart=socat -d -d -lm TCP4-LISTEN:1026,fork,reuseaddr,so-bindtodevice=docker0,range=172.17.0.0/24 TCP4:127.0.0.1:1025
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
Notes:
-
We configured Socat to listen to all IPs
172.17.0.0/24
, port1026
, and redirect the traffic to127.0.0.1:1025
, where Protonmail Bridge is listening -
Example from Socat documentation: <strong>socat</strong>
-
-d -d will print the fatal, error, warning, and notice messages; you may not want that much detail logged
Next, start the service:
systemctl start protonsocat
Check that it is running:
systemctl status protonsocat
And automatically get it to start on boot:
systemctl enable protonsocat
Done! Now, configure Discourse app.yml
and rebuild:
DISCOURSE_SMTP_ADDRESS: 172.17.0.1
DISCOURSE_SMTP_PORT: 1026
DISCOURSE_SMTP_USER_NAME: <SMTP username supplied by the Proton Bridge command-line application>
DISCOURSE_SMTP_PASSWORD: "<SMTP password - put in quotes>"
DISCOURSE_SMTP_ENABLE_START_TLS: true
DISCOURSE_SMTP_DOMAIN: <the domain name>
DISCOURSE_NOTIFICATION_EMAIL: <here, put the address form which Discourse will send transactional emails>