I’m trying to run a hedgedoc with its db and be able to access it via a nginx reverse proxy but I have some problems of comprehension.
I want hedgedoc and my reverse proxy to be on separate networks but still be able to communicate
But it doesn’t work. When I go to hedgedoc.localhost:8080 it shows me the nginx welcome page
And hedgedoc.localhost:3000 shows me the hedgedoc page but without any js
My docker compose file:
version: "3"
services:
reverse_proxy:
build:
context: ./nginx
container_name: reverse_proxy
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
network_reverse_proxy:
ports:
- 443:443
- 8080:8080
restart: always
database:
image: mariadb:10
environment:
- MYSQL_USER=hedgedoc
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=hedgedoc
- MYSQL_ALLOW_EMPTY_PASSWORD=true
volumes:
- database:/var/lib/mysql
- ./resources/utf8.cnf:/etc/mysql/conf.d/utf8.cnf
networks:
network_hedgedoc:
restart: always
hedgedoc:
image: lscr.io/linuxserver/hedgedoc:latest
container_name: hedgedoc
hostname: hedgedoc
environment:
- PUID=1000
- PGID=1000
- CMD_DB_URL=mysql://hedgedoc:password@database:3306/hedgedoc
- CMD_DOMAIN=hedgedoc.localhost
- CMD_URL_ADDPORT=false #optional
- CMD_PROTOCOL_USESSL=false #optional
- CMD_PORT=3000 #optional
- CMD_ALLOW_ORIGIN=['localhost'] #optional
volumes:
- uploads:/hedgedoc/public/uploads
ports:
- 3000:3000
restart: always
networks:
network_hedgedoc:
network_reverse_proxy:
depends_on:
- database
networks:
network_hedgedoc:
network_reverse_proxy:
volumes:
database:
uploads:
The nginx default.conf:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name hedgedoc.localhost;
location / {
proxy_pass http://hedgedoc:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /socket.io/ {
proxy_pass http://hedgedoc:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
listen 8080;
}
I have these questions:
How does nginx know how to access hedgedoc ? Via its hostname hedgedoc ?
How does the localhost of the network_reverse_proxy differ from the localhost of network_hedgedoc?
Why it doesn’t work ?
Still new to all of this, so sorry if these are silly questions
Ps:sorry for my english