Configure a firewall for Discourse

(Jeff Atwood) #1

It’s unclear if Linux distributions really “need” a firewall – but we have found that the following Uncomplicated Firewall rules work fine with a standard Docker based Discourse install:

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.

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 firewall should not matter if you are using a default Docker install of Discourse, for the same reason almost no Linux distribution ships with a firewall enabled by default.

But if you have somehow installed extra services that talk to the outside world, adding a firewall gives you “belt and suspenders” security, if that is of interest to you.

Multisite configuration with Docker
How to connect to pg database in console in Discourse installation?
Losing connection with Redis
Problem with POP3 PollMailbox Job
(Florian Bender) #2

Since SSH was (pretty much?) removed from the Docker image / launcher script, configuring the firewall without allowing SSH should work fine now, shouldn’t it?

(Jeff Atwood) #3

No, you are thinking of inside the docker container. That is already “firewalled” since only certain ports are allowed to talk to the container.

This would be SSH to the host machine, not the docker container inside it.