# Configure a firewall for Discourse

**URL:** https://meta.discourse.org/t/configure-a-firewall-for-discourse/20584
**Category:** Self-Hosting
**Tags:** configuring, how-to
**Created:** [September 29, 2014, 9:44am UTC](https://meta.discourse.org/t/configure-a-firewall-for-discourse/20584 "2014-09-29T09:44:21Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [September 29, 2014, 9:44am UTC](https://meta.discourse.org/t/configure-a-firewall-for-discourse/20584/1 "2014-09-29T09:44:21Z")

</div>

If you are using a standard Docker based Discourse install, the following [Uncomplicated Firewall](https://wiki.ubuntu.com/UncomplicatedFirewall) 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 `iptables` directly](https://docs.docker.com/network/packet-filtering-firewalls/) 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:

---

_[View the full topic](https://meta.discourse.org/t/configure-a-firewall-for-discourse/20584)._
