Install Discourse with Docker in a Subfolder with SSL and serve other content with nginx under the same domain

Discourse is a great free and open-source forum software.
There is an Linux installation guide with docker, but Discourse runs with a subdomain like discourse.example.com. I want Discourse run in a subfolder like example.com/forum.

There is a guide how to do this, but how to configure the nginx server to serve other content (example.com/index.html or example.com/otherContent) on the same machine?

  1. install discourse with docker on a linux server https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md

  2. change the port of the docker container and setup SSL with Let’s Encrypt (don’t use the subdomain like discourse.example.com use example.com) https://www.digitalocean.com/community/tutorials/how-to-install-discourse-behind-nginx-on-ubuntu-14-04

  3. create a folder for all the other content for your site

sudo mkdir -p /var/www/example.com/html

if necessary change the owner to you or www-data

sudo chown -R www-data:www-data /var/www/example.com/html

This is the root folder for your domain example.com
Dont create a forum folder here, it will cause a conflict with the discourse docker redirect!

  1. change the /etc/nginx/sites-enabled/discourse to this and replace http://discourse.example.com with your url (use main url not subdomain)

server {
        listen 80;
        server_name example.com;
        return 301 https://example.com$request_uri;
}
server {
        listen 443 ssl spdy;
        server_name example.com;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AE$
        ssl_prefer_server_ciphers on;

        location / {
                root /var/www/example.com/html;
        }

        location /forum/ {
                proxy_pass      http://example.com:25654/;
                proxy_read_timeout      90;
                proxy_redirect  http://example.com:25654/ https://example.com/;
        }
}
  1. restart nginx
sudo service nginx restart

If you go to example.com/forum your Discourse site should appear and if you go to example.com you should see your index.html (if you created one).

Leave your vote

7 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.