reality meets eccentricity


Getting “Bad Gateway” when setting up Stalwart in Docker? This may solve it.

Categories:

When Setting up Stalwart v0.16.x as a Docker container behind a reverse proxy, I ran head-first into one its security features, Autoban.

Because every connection to Stalwart goes through Docker, everything seems to come from a single IP address, which at some point will trigger Autoban and add the Docker bridge to the blocklist and nothing will get through from then on.

If you are getting “Bad Gateway” you can use recovery mode (https://stalw.art/docs/configuration/recovery-mode/) – you set the two environment variables STALWART_RECOVERY_MODE="1" and STALWART_RECOVERY_ADMIN="admin:STRONGPASSWORD” – setting your own stong password – but remember to block public access so only you can connect since this will disable all security features.

Now you should be able to access the WebUI, then to to Settings > Security > Blocked IPs and remove Docker’s IP from the list, and add it to the Allowed IPs list. As you (should) have configured the reverse proxy to set the X-Forwarded-For header, ensure you have set Settings > Network > HTTP > General > Obtain remote IP from Forwarded header to On.

Removing the above environment variables and restarting the Stalwart Docker container, you should be good to go!

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? Please solve:Captcha