Use Nginx Proxy Manager to manage multiple sites with Discourse

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.

1 Like

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;

  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 ?

1 Like

my docker-compose file

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:

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
1 Like

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

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

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.

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

This is because

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.

2 Likes

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 ?

1 Like

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.

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.

2 Likes

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.

1 Like

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

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

1 Like