Use Nginx Proxy Manager to manage multiple sites with Discourse

Just a small how-to for installing multiple instances :disguised_face:

In this case, we’ll start with a clean server install and we might want to restore an old instance afterwards.

Step 0: Backup!!!

Download the backup. You’ll need it later.

Step 1: NGINX Proxy Manager

mkdir -p /opt/nginx-proxy-manager
cd /opt/nginx-proxy-manager
nano docker-compose.yml
version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    ports:
      - '80:80'    # http / reserved! 
      - '81:81'    # web-admin port
      - '443:443'  # https / reserved!  
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

and finally: docker-compose up -d

(For even more lazy people, like me sometimes, just use casaOS (on any port other than ≠ 80/81/443). Just make sure you’re using secure login credentials and an extra proxy host with your SSL certificate for an extra layer of security. You can even set up some firewall rules if you know what you’re doing.

Step 2: Docker install on Ubuntu server

sudo apt update && apt upgrade -y

sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Step 3: Discourse install preparation

git clone https://github.com/discourse/discourse_docker.git /var/discourse

cp /var/discourse/samples/standalone.yml /var/discourse/containers/app1.yml
nano /var/discourse/containers/app1.yml

cp /var/discourse/samples/standalone.yml /var/discourse/containers/app2.yml
nano /var/discourse/containers/app2.yml

Make any necessary changes to your app.yml files. This includes different exposed ports for each instance (yes, you can even use them for maintenance), mail settings, and so on.

e.g. app1 gets port 8080/1443 and app2 gets port 8081/2443 for http/https.

/var/discourse/launcher rebuild app1
/var/discourse/launcher rebuild app2

Step 4: Last but not least configuring the NGINX Proxy Manager

Watch this for a basic understanding of using the NGINX Proxy Manager.

All you need to do is point your proxy host entries to each instance (http port, e.g. 8080 and 8081 with your local or public IP, it’s your decition) and you’ll be able to get free Let’s Encrypt certificates for each instance & domain. Just make sure you’re enabling Force SSL and so on.

Step 5: Done. Drink a cup of coffee.

In my case it works perfectly.

There may be some minor issues with the pre-installed software dependencies, but I’m sure you’ll find a solution. Don’t be mad at me for my casaOS tip. But for people who like to play around with their servers, use all available resources in an easy-to-use safe & secure way, I’m sure you’ll find this Docker management interesting.

Step 6: Finally, restore your previous backups.

1 Like