Use Nginx Proxy Manager to manage multiple sites with Discourse

Here’s my version of this. I almost gave up, but @tophee linked to a post that I (!?) wrote that provided the necessary magic! This is now a straight-forward way to configure Nginx Proxy Manager for Discourse. I think this makes this similar to Running other websites on the same machine as Discourse - #396.

Install Nginx Proxy Manager per their instructions at

Remove SSL and Let’s Encrypt templates:

See that these lines in your yml file are commented out or deleted:

## Uncomment these two lines if you wish to add Lets Encrypt (https)
#- "templates/web.ssl.template.yml"
#- "templates/web.letsencrypt.ssl.template.yml"

Have Discourse use the npm-default network.

If you blindly follow the Nginx Proxy Manager install instructions, it will create a docker network called npm_default.

Add this stanza to your yml file(s). If you have separate web_only and data containers, you’ll need to add this to each of them (I didn’t test the mail-receiver container.). docker_args is not indented.

docker_args: |
  --network npm_default

No need to expose any ports

Comment out or remove these lines from your yml file:

# expose:
#  - "80:80"   # http
#  - "443:443" # https

You can then rebuild your container(s) and configure Nginx Proxy Manager like this:

image

A simple (but not necessarily recommended) way to spin up a second Discourse site would be this:

cd /var/discourse/containers
cp app.yml othersite.yml
# somehow edit, at a minimum, the hostname in othersite.yml
./launcher rebuild othersite

Then add it to NPM as above, using othersite instead of app.

I tested this with an app.yml plus two web_only-style containers and a single data container plus a separate othersite-redis container that is a copy of the data container containing only the redis templates. (But an easier solution would be to put the extra redis in the web_only container).

2 Likes