Step 1: Preparation for Installation

First, create a directory for Discourse and clone the repository:

sudo mkdir /var/discourse
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

Step 2: Configuring Discourse

Run the Discourse setup:

sudo ./discourse-setup

By default, the forum will be accessible at forum.domain.com. To change settings to work with a subfolder, edit the file:

sudo nano /var/discourse/containers/app.yml

Add the parameter DISCOURSE_RELATIVE_URL_ROOT: /forum. Change ports to 8080, as ports 80 and 443 will be used by Apache with ProxyPass to 8080.

  - "8080:80"   # http
#  - "8443:443" # https

You can download the ready-edited file app.yml here

Step 4: Rebuilding Discourse

Rebuild Discourse after making changes to the file:

cd /var/discourse
sudo ./launcher rebuild app

After rebuilding, make sure there are no errors and the container is running

docker ps

Step 5: Configuring Apache

Install and configure Apache as a proxy server:

sudo apt update
sudo apt install apache2
sudo a2enmod proxy
sudo a2enmod ssl
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer

Create a new configuration file for the Discourse virtual host:

sudo nano /etc/apache2/sites-available/discourse.conf

 

Add the following configuration, replacing the domain and SSL path with your own:

<VirtualHost *:80>
    ServerName test.domain.com
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:443>
    ServerName test.domain.com
    DocumentRoot /var/www/html
    ProxyPass /forum http://test.domain.com:8080/forum
    ProxyPassReverse /forum http://test.domain.com:8080/forum

    SSLEngine on
    SSLCertificateFile /etc/ssl/test.domain.com/test.domain.com.cer
    SSLCertificateKeyFile /etc/ssl/test.domain.com/test.domain.com.key
    SSLCertificateChainFile /etc/ssl/test.domain.com/test.domain.com_chain.cer
</VirtualHost>

Enable the new virtual host and restart Apache:

sudo a2ensite discourse
sudo systemctl restart apache2

Step 6: Checking Status

Check the Apache status to ensure there are no errors:

systemctl status apache2

Now your forum will be accessible at https://domain.com/forum.

Comments:
There are no comments for this post yet.
Log in to leave a comment.