DEV Community

Kofi Mupati
Kofi Mupati

Posted on



Discourse is a great platform for creating discussion forums for different purposes. It is an Open Source project and can be self-hosted. You can check out the various pricing packages offered by Discourse on their Cloud Hosting.
This tutorial was greatly inspired by the following articles:

  1. Discourse Installation Guide
  2. Tutorial on How To Forge

I could not get it to run by just following the tutorials. I encountered some issues because I already had a lot of websites on various subdomains hosted on my server. This is to explain any similarity that is seen in my article to address any plagiarism concern.


  • You should own a server. I used my droplet on Digital Ocean for this.
  • Have Nginx installed and configured on the server. Learn how to do it over here.
  • Have a personal email/ mail server attached to your domain. In this tutorial, we will use Zoho mail. It is affordable and provides 5 free e-mails albeit, with some limitations.

Create Subdomain on Digital Ocean

Create the subdomain you want to use for the discussion forum you are creating with Discourse on your existing droplet.
The one I will use in this tutorial is

Stop The Web server - Nginx

sudo systemctl stop nginx
Enter fullscreen mode Exit fullscreen mode

I had to stop the webserver because the configurations in the Discourse image was conflicting with Nginx.

Download and Install Discourse as a sudo user

sudo git clone /var/discourse
cd /var/discourse 
sudo ./discourse-setup
Enter fullscreen mode Exit fullscreen mode

Go through the installation process and answer the questions that are posed.

Hostname for your Discourse? []: 
Email address for admin account(s)? []: 
SMTP server address? []: 
SMTP port? [587]: 
SMTP user name? []: 
SMTP password? [password_of_the_email]: 
Let's Encrypt account email? (ENTER to skip) []: 
Enter fullscreen mode Exit fullscreen mode

After the installation, open the subdomain in your browser. In my case, You should see a welcome screen that walks you through the registration process.

The Challenge

I faced an issue where the activation email that is supposed to be sent through never hits my inbox.
To fix this, we stop the running container and edit the /var/discourse/containers/app.yml file. Locate the lines

  • Stop the docker container the Discourse installation is running on.
cd /var/discourse
sudo ./launcher stop app
Enter fullscreen mode Exit fullscreen mode
  • Change the port number that is exposed in the docker config. Note the port number. It will also be used in setting up Reverse Proxy on Nginx virtual host for the subdomain.
  - "80:80"   # http
changes to
  - "3035:80"   # http
Enter fullscreen mode Exit fullscreen mode
  • Set the notification email in the config to be used for the initial setup.
#- exec: rails r "SiteSetting.notification_email=''"
changes to
- exec: rails r "SiteSetting.notification_email=''"
Enter fullscreen mode Exit fullscreen mode

Set Up Virtual Host for the Subdomain.

  • Start Nginx once again.

sudo systemctl start nginx

  • Create a file /etc/nginx/sites-available/ Replace with your subdomain.
  • Place these configs in these files and save them.
server {
 listen 80; listen [::]:80;
 return 301 https://$host$request_uri;

 include /etc/nginx/ssl/ssl-params.conf;

server {
  listen 443 ssl http2;  

  location / {
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Enter fullscreen mode Exit fullscreen mode
  • Contents of /etc/nginx/ssl/ssl-params.conf
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;

    ssl_ecdh_curve secp384r1;

    resolver valid=300s;
    resolver_timeout 5s;

    add_header Strict-Transport-Security "max-age=604800";

    add_header X-Content-Type-Options nosniff;

    ssl_session_timeout  10m;
    ssl_stapling on;
    ssl_stapling_verify on;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
Enter fullscreen mode Exit fullscreen mode
  • Activate the virtual host you created and check whether Nginx settings are correct.
sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo nginx -t
Enter fullscreen mode Exit fullscreen mode

Rebuild Discourse App with the new configurations

After editing the /var/discourse/container/app.yml file, we have to rebuild our Discourse App.

cd /var/discourse
sudo ./launcher rebuild app
Enter fullscreen mode Exit fullscreen mode

Complete the Installation

Open the subdomain ( in my case) in the browser and complete the installation.
This time the activation email should hit your inbox and you should be able to complete the installation.

It is advised that the notification email that you set in the /var/discourse/container/app.yml be commented out after successful installation and rebuild the app.

- exec: rails r "SiteSetting.notification_email=''"
changes back to
#- exec: rails r "SiteSetting.notification_email=''"
Enter fullscreen mode Exit fullscreen mode

This is the only way I was able to successfully set up the biggest discussion forum for SMEs in Ghana; SME GHANA after struggling to use the various tutorials that are available.

Further additions - Configuring SSL

YOu can further configure SSL for your subdomain using Let's Encrypt

Top comments (0)