If you are using a standard Docker based Discourse install, the following Uncomplicated Firewall rules will protect any non-Docker services on your server:
ufw allow http
ufw allow https
ufw allow ssh
ufw enable
That is, allow HTTP (port 80), HTTPS (port 443), and SSH (port 22), and nothing else.
Note: Docker manipulates
iptablesdirectly and bypasses ufw rules. This means ufw cannot block or restrict access to ports exposed by Docker containers (ports 80 and 443 in a standard Discourse install). The ufw rules above will only protect non-Docker services running on your host.
Check the current status of your firewall with
ufw status verbose
Sample output:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
80 ALLOW IN Anywhere
443 ALLOW IN Anywhere
22 ALLOW IN Anywhere
80 (v6) ALLOW IN Anywhere (v6)
443 (v6) ALLOW IN Anywhere (v6)
22 (v6) ALLOW IN Anywhere (v6)
And if you ever want to turn it off
ufw disable
A default Docker install of Discourse only exposes ports 80 and 443, so a host firewall is not strictly necessary. But if you have other services running on the host that listen on additional ports, adding a firewall provides an extra layer of “belt and suspenders” security for those services.
Last edited by @JammyDodger 2024-05-25T11:25:44Z
Check document
Perform check on document: