I have exactly the same problem as many other and this is really annoying. Everything is setup correctly, but still does not work at all. I read all posts and still did not find a solution.
You can try at: forum.mrw.sh — feel free to register, I'll reset the database as soon as the problem is fixed.
I have the following setup:
So user enters https://forum.mrw.sh
, which is directed to container mwaeckerlin/reverse-proxy
running on swarm master host named jupiter
, listening on external port 443
, which is port 8443
in the container. Then nginx redirects to http://jupiter:8036
which is redirected by the docker swarm lead master to the docker container nodebb/docker
which listens on external port 8036
, which is port 4567
in the container.
So, what exactly is the url, that must be entered in config.json
?!? I suppose the url as it is visible from outside, which is https://forum.mrw.sh
?
Documentation of nodebb/docker
is extremely bad and incomplete! Especially the volumes that must be persistent are not specified! As far as I have seen, these are the config.json
file and the upload directory.
First, I have a problem: The docker image has a chickem-egg-problem with the config file: The config file should be mounted into the container, but it is created in the container and creating an empty config file at startup fails. Better solution: specify a configuration directory and mount the whole directory. But this means to specify an alternate directory, but that does not work with the ./nodebb
script! Also, calling node src/cli --config /etc/nodebb/config.json start
does not work, first it must be built.
So I had to change the docker command to: /bin/bash -c "node src/cli --config /etc/nodebb/config.json bui
ld && node src/cli --config /etc/nodebb/config.json start"
Next question is: What will happen on nodebb updates?
Anyway, this is the configuration:
Docker:
version: '3.3'
services:
mongodb:
image: mongo
volumes:
- type: bind
source: /srv/volumes/forum-mrw-sh/mongodb
target: /data/db
deploy:
resources:
limits:
memory: 1G
nodebb:
image: nodebb/docker
ports:
- 8036:4567
labels:
- 'url=https://forum.mrw.sh'
volumes:
- type: bind
source: /srv/volumes/forum-mrw-sh/nodebb
target: /etc/nodebb
environment:
- CONFIG=/etc/nodebb/config.json
command: /bin/bash -c "node src/cli --config /etc/nodebb/config.json build && node src/cli --config /etc/nodebb/config.json start"
deploy:
resources:
limits:
memory: 1G
config.json:
{
"url": "https://forum.mrw.sh",
"secret": "****",
"database": "mongo",
"port": 4567,
"mongo": {
"host": "mongodb",
"port": "27017",
"database": "nodebb"
}
}
Nginx:
map $http_accept_language $lang {
default en;
~*^de de;
}
server { # redirect http to https
listen 80;
server_name forum.mrw.sh;
server_name www.forum.mrw.sh;
location /.well-known {
alias /acme/.well-known;
}
location / {
return 302 https://forum.mrw.sh:443$request_uri;
}
}
server { # redirect www to non-www
listen 443 ssl http2;
server_name www.forum.mrw.sh;
add_header Strict-Transport-Security max-age=15552000 always;
return 302 $scheme://forum.mrw.sh:443$request_uri;
ssl on;
ssl_certificate /etc/letsencrypt/live/forum.mrw.sh/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/forum.mrw.sh/privkey.pem;
}
server {
listen 443 ssl http2;
server_name forum.mrw.sh;
add_header Strict-Transport-Security max-age=15552000 always;
ssl on;
ssl_certificate /etc/letsencrypt/live/forum.mrw.sh/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/forum.mrw.sh/privkey.pem;
error_page 502 /502.html;
error_page 504 /504.html;
error_page 404 /404.html;
location ~ ^/(502|504|404)\.html$ {
root /etc/nginx/error/$lang;
}
location ~ ^/(502|504|404)\.jpg$ {
root /etc/nginx/error;
}
location / {
include proxy.conf;
if ($request_method ~ ^COPY$) {
rewrite /(.*) /$1 break;
}
proxy_cookie_domain jupiter forum.mrw.sh;
proxy_pass http://jupiter:8036/;
proxy_redirect off;
}
location /.well-known {
alias /acme/.well-known;
}
}
proxy.conf:
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
set $ssl off;
if ($scheme = https) {
set $ssl on;
}
proxy_set_header X-Forwarded-Ssl $ssl;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Original-Request $request_uri;
proxy_pass_request_headers on;
#proxy_cache off;
#proxy_buffering off;
client_max_body_size 4096m;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 86400;
send_timeout 600;
proxy_buffers 32 4k;
#subs_filter_types text/css text/javascript text/xml;
set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ ) {
set $fixed_destination http$1;
}
proxy_set_header Destination $fixed_destination;
proxy_ssl_verify off;
# WebSocket proxying
# http://nginx.org/en/docs/http/websocket.html
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# referrer-policy
add_header "Referrer-Policy" "no-referrer";
And in the Log:
NodeBB v1.10.2 Copyright (C) 2013-2014 NodeBB Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions.
For the full license, please visit: http://www.gnu.org/copyleft/gpl.html
Clustering enabled: Spinning up 1 process(es).
2018-11-23T10:58:24.570Z [65] - info: Initializing NodeBB v1.10.2 https://forum.mrw.sh
2018-11-23T10:58:24.735Z [65] - warn: You have no mongo username/password setup!
2018-11-23T10:58:30.466Z [65] - warn: You have no mongo username/password setup!
2018-11-23T10:58:30.490Z [65] - info: [socket.io] Restricting access to origin: https://forum.mrw.sh:*
2018-11-23T10:58:31.929Z [65] - info: Routes added
2018-11-23T10:58:31.933Z [65] - info: NodeBB Ready
2018-11-23T10:58:31.943Z [65] - info: Enabling 'trust proxy'
2018-11-23T10:58:31.949Z [65] - info: NodeBB is now listening on: 0.0.0.0:4567
So: What's the problem?
Principially, socks.js
and node.js
works in my projects in the same environment, but I never restricted access to origin for socks.js
.