DEV Community

Cover image for How to Set Up a Self-Hosted Forum When You're Tired of Renting Your Community
Alan West
Alan West

Posted on

How to Set Up a Self-Hosted Forum When You're Tired of Renting Your Community

You wake up one morning and your Discord server got nuked. Or maybe Slack changed their free tier again and your community just lost 10,000 messages of searchable knowledge. Or Reddit decided your subreddit violates some new policy you've never heard of.

I've been through two of these three scenarios. The second time it happened — watching months of technical discussions vanish from a free Slack workspace — I finally sat down and solved this properly.

Here's the core problem and how to fix it.

The actual problem: you don't own your community's data

When your project discussions live on a third-party platform, you're one terms-of-service change away from losing everything. This isn't paranoia. It's happened repeatedly:

  • Slack's free tier message limits have changed multiple times
  • Discord servers get disabled with little warning or recourse
  • Hosted forum platforms shut down and give you weeks to export
  • API changes break integrations you depend on

Beyond data loss, there's a subtler issue. You can't customize the experience. You can't add custom authentication. You can't control what gets indexed by search engines. You can't decide your own moderation policies without platform interference.

The fix is straightforward: run your own forum software on infrastructure you control.

Choosing the right self-hosted forum software

I've deployed three different forum platforms across various projects. Here's what I'd actually recommend in 2026:

  • Discourse — Ruby on Rails, PostgreSQL, Redis. The most fully-featured option. Great search, solid plugin ecosystem, handles large communities well. Heavier on resources.
  • Flarum — PHP, MySQL. Lightweight, modern UI, easier to extend if you know PHP. Smaller community but active development.
  • NodeBB — Node.js, MongoDB or Redis. Good real-time features, familiar stack if you're a JS developer.

I'm going with Discourse for this walkthrough because it's what I've run the longest and trust the most in production.

Step 1: Provision your server

You need a VPS with at least 2GB of RAM (Discourse won't install on 1GB without swap, and even then it's painful). I've had good results with 2 vCPUs and 4GB RAM for communities under 5,000 users.

SSH into your fresh server and make sure it's up to date:

# Update packages and install prerequisites
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget

# Discourse uses Docker, so install that
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
Enter fullscreen mode Exit fullscreen mode

One thing that tripped me up the first time: Discourse's installer assumes it has exclusive use of ports 80 and 443. If you're running anything else on those ports, you'll need to put Discourse behind a reverse proxy. More on that in a minute.

Step 2: Clone and configure Discourse

Discourse ships its own Docker-based installer that handles most of the complexity:

# Clone the official Docker deployment repo
sudo -s
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

# Run the interactive setup
./discourse-setup
Enter fullscreen mode Exit fullscreen mode

The setup script asks for your domain, SMTP credentials, and admin email. Don't skip the SMTP part — Discourse relies heavily on email for account confirmation and notifications. I learned this the hard way when half my users couldn't activate their accounts because I figured I'd "set up email later."

If you want more control, you can edit the config directly:

# /var/discourse/containers/app.yml
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"  # add this if using a reverse proxy

params:
  db_default_text_search_config: "pg_catalog.english"

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: en
  DISCOURSE_HOSTNAME: 'forum.yourdomain.com'
  DISCOURSE_DEVELOPER_EMAILS: 'you@yourdomain.com'
  DISCOURSE_SMTP_ADDRESS: smtp.yourmailprovider.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: your-smtp-user
  DISCOURSE_SMTP_PASSWORD: your-smtp-password
  # Uncomment the next line if you're behind a reverse proxy
  # DISCOURSE_SMTP_ENABLE_START_TLS: true

volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log
Enter fullscreen mode Exit fullscreen mode

Then build and launch:

./launcher rebuild app
Enter fullscreen mode Exit fullscreen mode

This takes 5-10 minutes. Go make coffee.

Step 3: Set up a reverse proxy (if you need one)

If you're running other services on the same box — and you probably are if you're into self-hosting — you'll want nginx or Caddy in front of Discourse.

I use Caddy because the automatic HTTPS is genuinely zero-config:

# Install Caddy
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update && sudo apt install caddy
Enter fullscreen mode Exit fullscreen mode

Then configure it:

# /etc/caddy/Caddyfile
forum.yourdomain.com {
    reverse_proxy unix//var/discourse/shared/standalone/nginx.http.sock
}
Enter fullscreen mode Exit fullscreen mode

Restart Caddy with sudo systemctl restart caddy and you've got automatic TLS termination. No certbot cron jobs, no renewal scripts. It just works.

Step 4: Backups — the part everyone skips

Here's where digital sovereignty actually matters. If your server dies and you have no backups, you've just recreated the same problem you were trying to avoid.

Discourse has built-in backup support via the admin panel, but I also run a cron job that copies backups off-server:

# /etc/cron.d/discourse-backup
# Run backup daily at 3am, then sync to remote storage
0 3 * * * root /var/discourse/launcher run app discourse backup
30 3 * * * root rsync -avz /var/discourse/shared/standalone/backups/ backup-user@your-backup-server:/backups/discourse/
Enter fullscreen mode Exit fullscreen mode

Test your restore process before you need it. I cannot stress this enough. A backup you've never tested is not a backup — it's a hope.

Step 5: Harden the basics

A few things you should do before inviting anyone:

  • Enable 2FA for all admin accounts immediately
  • Set up fail2ban to block brute-force attempts on your SSH and any exposed services
  • Configure unattended-upgrades so security patches apply automatically
  • Restrict SSH to key-based auth only — disable password login
  • Set up monitoring — even something simple like uptime checks so you know when things break

Discourse also has rate limiting built in (that web.ratelimited.template.yml template from earlier), which helps with spam and abuse.

Why not just use a managed Discourse instance?

Fair question. The official Discourse hosting starts around $50/month for small communities. If you value your time more than that monthly cost, managed hosting is completely reasonable.

But the whole point of this exercise is sovereignty. With a managed instance, you're still dependent on someone else's infrastructure decisions, pricing changes, and continued existence as a business. Self-hosting means the forum lives and dies by your own decisions.

There's also the learning aspect. Running your own forum teaches you about email deliverability, Docker networking, backup strategies, and reverse proxies. Every one of those skills transfers to other projects.

The maintenance reality

I won't pretend self-hosting is set-and-forget. Here's what ongoing maintenance actually looks like:

  • Updates: Discourse releases frequently. Run ./launcher rebuild app every few weeks. It takes about 5 minutes of downtime.
  • Disk space: Uploaded images and attachments add up. Monitor your disk usage.
  • Email reputation: If your SMTP setup isn't right, your forum's emails end up in spam. Check your SPF, DKIM, and DMARC records.
  • Spam: It will come. Discourse has decent built-in anti-spam tools, but you'll still need to tune settings as your community grows.

Budget about 1-2 hours per month for maintenance once everything is running smoothly. More in the first month as you dial in settings.

The real payoff

Six months after migrating my project's community from a free Slack workspace to a self-hosted Discourse instance, here's what changed:

  • Every discussion is searchable and indexed by search engines, bringing in new community members organically
  • Knowledge doesn't disappear behind message limits
  • I own the data and can export it in standard formats anytime
  • The community feels more permanent, which encourages people to write longer, more thoughtful posts

Self-hosting a forum isn't hard. It's a weekend project that pays dividends for years. The hardest part isn't the technical setup — it's convincing your community to make the move. But that's a people problem, not a tech problem, and it's outside the scope of what I can solve with a Docker container.

Top comments (0)