# Gebruik Nginx Proxy Manager om meerdere sites met Discourse te beheren

**URL:** https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344
**Category:** Sysadmins
**Tags:** how-to
**Created:** [17 augustus 2021 om 08:21 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344 "2021-08-17T08:21:04Z")
**Posts on this page:** 14
**Page:** 2

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [20 januari 2022 om 21:41 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/24 "2022-01-20T21:41:39Z")

</div>

You need to see that both containers are on the same docker network. If you don’t have NPM working then you don’t (yet) have a Discourse configuration problem.

---

<div class="post-metadata">

### Author: ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)
#### Post date: [20 januari 2022 om 21:44 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/25 "2022-01-20T21:44:27Z")

</div>

i mistakly forget the maria db docker network; but after adding

` network_mode: bridge`

i still get npm error in connect to the discourse database;

```plaintext
  environment:
      DB_MYSQL_HOST: "172.17.0.2" #data container - but i receive error ( error connect ECONNREFUSED 172.17.0.2:3306 ) when enabled.
# DB_MYSQL_HOST: "db" default npm databse (outside discourse).
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "h4xb0xr1z__0k"
      DB_MYSQL_NAME: "npm"

```

when npm and maria comes up and running; the logs of maria good… but npm

`error connect ECONNREFUSED 172.17.0.2:3306`

any missing ?

---

<div class="post-metadata">

### Author: ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)
#### Post date: [20 januari 2022 om 21:45 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/26 "2022-01-20T21:45:47Z")

</div>

my docker-compose file

```plaintext
version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    network_mode: bridge
    restart: unless-stopped
    ports:
    
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port

    environment:
      DB_MYSQL_HOST: "172.17.0.2" #data container - but i receive error ( connect ECONNREFUSED 172.17.0.2:3306 ) when enabled.
# DB_MYSQL_HOST: "db" default npm databse (outside discourse).
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "mypassword"
      DB_MYSQL_NAME: "npm"

    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
# depends_on:
# - db

  db:
    image: 'mariadb:latest'
    restart: unless-stopped
    network_mode: bridge
    environment:
      MYSQL_ROOT_PASSWORD: 'mypassword'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'mypassword'
    volumes:
      - ./data/mysql:/var/lib/mysql

```

i have discourse running with data + web-only; the map for IP’s after npm and maria is like this:

```plaintext
data container IP: 172.17.0.2
web_only container IP: 172.17.0.3
npm container IP: 172.17.0.5
maria data (npm) IP: 172.17.0.4

```

---

<div class="post-metadata">

### Author: ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)
#### Post date: [21 januari 2022 om 09:21 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/27 "2022-01-21T09:21:34Z")

</div>

Hi @tophee

Can you give us your recommendation on using SQLite with NPM, since it’s more easy and trusted to work with than mariadb issue’s;

I have setup NPM with SQLite and everything working fine, nginx virtual host, ssl, etc… but i want make sure how to connect the database of discourse with NPM ? since i’m getting 502 error for the npm setup with the discourse site.

my docker-compose

```plaintext
version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: always
    network_mode: bridge <-- this network has been added to let NPM be in same discourse network, and they now see each others.
    ports:
      # Public HTTP Port:
      - '80:80'
      # Public HTTPS Port:
      - '443:443'
      # Admin Web Port:
      - '81:81'
    environment:
      DB_SQLITE_FILE: "/data/database.sqlite"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

```

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [23 januari 2022 om 07:59 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/28 "2022-01-23T07:59:18Z")

</div>

> [@f1r4s](#):
>
> Can you give us your recommendation on using SQLite with NPM,

No, my recommendation is to use NPMs standard setup unless you know what you’re doing. That’s the reason why I’m using the standard setup.

> [@f1r4s](#):
>
> any suggestion to let step 3. working with me ?

You don’t need step 3 if you connect the discourse container via websocket.

> [@f1r4s](#):
>
> `getaddrinfo ENOTFOUND db <-- error when the mySQL in npm compose file defind as "db".`

This is because

> [@tophee](#):
>
> internal DNS resolution for service names (which the docker-compose file relies on) is only available on user created networks

> [@f1r4s](#):
>
> error connect ECONNREFUSED 172.17.0.2:3306

Are you sure that `172.17.0.2` is your db container? - In any case: you can skip this trouble by leaving NPM on its own network and connection discourse via web socket.

---

<div class="post-metadata">

### Author: ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)
#### Post date: [26 januari 2022 om 14:42 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/29 "2022-01-26T14:42:56Z")

</div>

Thanks @tophee for clarification, i have done and correct everything, but seems i didn’t use websocket and i was focused on the port with npm setup and discourse’s containers;

my issue i face with NPM was with CloudFlared Argo tunnel, after i finish the setup of NPM, ssl, everything.. i managed to run CloudFlared argo tunnel but the issue was that CloudFlared cannot be run as a secondary proxy, were we need to disable NPM to be in front of the origin web; the error i get from CloudFlare is this:

`Error 1000: DNS points to prohibited IP`

after searching for this error with cloudflare; it’s give me this

`There is a reverse-proxy at your origin that sends the request back through the Cloudflare proxy. Instead of using a reverse-proxy, contact your hosting provider or site administrator to configure an HTTP redirect at your origin.`

How can we disable NPM as a reverse-proxy ?

My point is to make the orign IP works without NPM “while” npm is installed and working; so we can make cloudflared communicate with our server ?

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [26 januari 2022 om 15:01 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/30 "2022-01-26T15:01:05Z")

</div>

> [@f1r4s](#):
>
> How can we disable NPM as a reverse-proxy ?

Uninstall NPM. The whole point of NPM is to act as a reverse proxy. If you don’t want a reverse proxy, turn it off.

> [@f1r4s](#):
>
> My point is to make the orign IP works without NPM “while” npm is installed and working; so we can make cloudflared communicate with our server ?

I don’t quite get the point and this is certainly nothing have any knowledge about. You should probably check the NPM forum or something. This has nothing to do with discourse.

---

<div class="post-metadata">

### Author: ![f1r4s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/f1r4s/32/245347_2.png) [@f1r4s](https://meta.discourse.org/u/f1r4s)
#### Post date: [26 januari 2022 om 15:10 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/31 "2022-01-26T15:10:02Z")

</div>

I already did open there; and i discuss here also, and yes, i have disable it after 2 days playing around; but i would add how to i add custom port support with Discourse and NPM here, since this topic support only socket nginx with npm;

Thanks.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [26 januari 2022 om 15:20 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/32 "2022-01-26T15:20:41Z")

</div>

> [@f1r4s](#):
>
> i would add how to i add custom port support with Discourse and NPM here, since this topic support only socket nginx with npm;

No. It doesn’t only support sockets unless you follow the socket instructions. It says that you don’t have to use sockets:

> [@tophee](#):
>
> If you don’t care about using the websocket, I suppose you can just point NPM to port 80 (not 443) of your discourse container-IP, like this:

When I last tested this, it worked just fine using a port as suggested.

---

<div class="post-metadata">

### Author: ![Norike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/norike/32/299043_2.png) [@Norike](https://meta.discourse.org/u/Norike)
#### Post date: [17 maart 2023 om 16:39 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/33 "2023-03-17T16:39:05Z")

</div>

These instructions helped me to setup Discourse with Nginx Proxy Manager.  
However, the browser gives “mixed content” errors when trying to load fonts and images from http.

You can “force https” in links with the option here:

 ![imagen](https://global.discourse-cdn.com/meta/original/4X/1/9/1/191a1d50a9bd41b5e56d6cd7739415b34649dd15.png)

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [25 februari 2024 om 17:26 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/34 "2024-02-25T17:26:09Z")

</div>

Wow, that’s quite a complicated topic with lots of ifs and buts.

Today I also tried my hand at the setup and unfortunately failed miserably. The instructions have good intentions, but in my opinion they are not so easy to understand/comprehend.

When I work with Docker, I usually want the containers to run separately/isolated from each other. Not too many dependencies, prerequisites and “single points of failure”. But these are exactly the problems that are caused by the approach: NPM is a great tool. I don’t understand why I have to make special adjustments to its Docker configuration from the Proxy Manager to make Discourse happy and provide it with certificates. At home, I also use the NPM for my DynDNS domain so that I can flexibly assign services and hosts at any time. And to have some of them public (Home Assistant, Grafana, …).

I wanted to merge my two Discourse instances today. I have specially rented a cloud server from Hetzner/Germany. That’s why DIscourse wasn’t pre-installed, as the instructions assume.

I wish Discoruse would officially offer the installation with NPM by default. Or at least not make so much trouble with the ./discourse-setup script.

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [27 februari 2024 om 22:15 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/35 "2024-02-27T22:15:43Z")

</div>

# Just a small how-to for installing multiple instances 🥸

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

```plaintext
mkdir -p /opt/nginx-proxy-manager
cd /opt/nginx-proxy-manager
nano docker-compose.yml

```

```plaintext
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](https://casaos.io) (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

```plaintext
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

```plaintext
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.

```plaintext
/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.

[![](https://global.discourse-cdn.com/meta/original/4X/c/1/2/c127ca85a581596fe16d448edf5a7f048e1aac3d.jpeg "Quick and Easy Local SSL Certificates for Your Homelab!") ](https://www.youtube.com/watch?v=qlcVx-k-02E)

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.

---

<div class="post-metadata">

### Author: ![toeadeep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toeadeep/32/488142_2.png) [@toeadeep](https://meta.discourse.org/u/toeadeep)
#### Post date: [23 februari 2025 om 09:46 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/36 "2025-02-23T09:46:31Z")

</div>

can i combine this using clouflare tunnel for domain ?

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [23 februari 2025 om 10:58 UTC](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344/37 "2025-02-23T10:58:53Z")

</div>

Sure, why not?

Just make sure, you‘ll have to expose the right port and set up this port for your domain in Cloudflare tunnels.

Personally, I don’t prefer this solution because it makes me dependent to Cloudflare and every tunnel agent puts a hole 🕳 into my firewall, that makes me feel I‘m installing a trojan horse.

Firewall management is essential for server admins. You‘ll have some homework to do before exposing sites to the DMZ.

[Vorige pagina](https://meta.discourse.org/t/use-nginx-proxy-manager-to-manage-multiple-sites-with-discourse/206344.md?page=1)
