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.
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 ?
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
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.
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 ?
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.
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.
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.
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:
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.
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
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.