Introduction
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:
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.
Prerequisites
- 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 sme.ek-brandconsult.com
Stop The Web server - Nginx
sudo systemctl stop nginx
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 https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
sudo ./discourse-setup
Go through the installation process and answer the questions that are posed.
Hostname for your Discourse? [sme.ek-brandconsult.com]:
Email address for admin account(s)? [forum@ek-brandconsult.com]:
SMTP server address? [smtp.zoho.com]:
SMTP port? [587]:
SMTP user name? [forum@ek-brandconsult.com]:
SMTP password? [password_of_the_email]:
Let's Encrypt account email? (ENTER to skip) [me@domain.com]:
After the installation, open the subdomain in your browser. In my case, sme.ek-brandconsult.com. 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
- 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
- Set the notification email in the config to be used for the initial setup.
#- exec: rails r "SiteSetting.notification_email='mail@domain.com'"
changes to
- exec: rails r "SiteSetting.notification_email='forum@ek-brandconsult.com'"
Set Up Virtual Host for the Subdomain.
- Start Nginx once again.
sudo systemctl start nginx
- Create a file
/etc/nginx/sites-available/sme.ek-brandconsult.com
. Replacesme.ek-brandconsult.com
with your subdomain. - Place these configs in these files and save them.
server {
listen 80; listen [::]:80;
server_name sme.ek-brandconsult.com;
return 301 https://$host$request_uri;
include /etc/nginx/ssl/ssl-params.conf;
}
server {
listen 443 ssl http2;
server_name sme.ek-brandconsult.com;
location / {
proxy_pass http://sme.ek-brandconsult.com:3035/;
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;
proxy_redirect http://sme.ek-brandconsult.com:3035/ https://sme.ek-brandconsult.com;
}
}
- Contents of
/etc/nginx/ssl/ssl-params.conf
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_ecdh_curve secp384r1;
resolver 8.8.8.8 8.8.4.4 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;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
- Activate the virtual host you created and check whether Nginx settings are correct.
sudo ln -s /etc/nginx/sites-available/sme.ek-brandconsult.com /etc/nginx/sites-enabled/
sudo nginx -t
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
Complete the Installation
Open the subdomain (https://sme.ek-brandconsult.com 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='forum@ek-brandconsult.com'"
changes back to
#- exec: rails r "SiteSetting.notification_email='mail@domain.com'"
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)