The site loads properly on serverIP:5870 and if I change proxy_pass http://127.0.0.1:5870;
to proxy_pass http://listmonk.mydomain.com:5870;
then it will load on listmonk.mydomain.com:5870. But it gives the 502 error when I visit the site without the port.
If I set proxy_pass http://127.0.0.1:5870;
and visit listmonk.mydomain.com:5870 I get:
The connection for this site is not secure listmonk.mydomain.com sent an invalid response. [Try running Windows Network Diagnostics](javascript:diagnoseErrors()). ERR_SSL_PROTOCOL_ERROR
docker-compose.yml:
version: "3.7" x-app-defaults: &app-defaults restart: unless-stopped image: listmonk/listmonk:latest ports: - "5870:9000" networks: - listmonk environment: - TZ=Etc/UTC x-db-defaults: &db-defaults image: postgres:13 ports: - "9432:5432" networks: - listmonk environment: - POSTGRES_PASSWORD=pw - POSTGRES_USER=listmonk - POSTGRES_DB=listmonk restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U listmonk"] interval: 10s timeout: 5s retries: 6 services: db: <<: *db-defaults container_name: listmonk_db volumes: - type: volume source: listmonk-data target: /var/lib/postgresql/data app: <<: *app-defaults container_name: listmonk_app depends_on: - db volumes: - ./config.toml:/listmonk/config.toml - ./uploads:/listmonk/uploads networks: listmonk: volumes: listmonk-data:
nginx config:
server { listen 443 ssl; server_name listmonk.example.com; location / { proxy_pass http://127.0.0.1:5870; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name listmonk.example.com; location / { return 301 https://$host$request_uri; } }
bigredgiraffe@lemmy.world 11 months ago
the purpose of using nginx is to not have to use the port number in this scenario, the reason it works is because your DNS for that hostname still points to that machine that both containers are running on. Normal DNS A and cname records do not contain port information.
The 502 bad gateway error means that nginx is not able to connect to the upstream host for that hostname, this is where you need to use the port for the other container (5870). Do know that using localhost in docker will not have the results you are expecting, if these are on the same host you can use the name you have configured for the container as the hostname in nginx otherwise use the host IP, in your case it would be http://listmonk_app:5870.
Hope that helps!
MaximilianKohler@lemmy.world 11 months ago
Thanks! I had tried variations of
proxy_pass http://app:5870;
because I’m running listmonk successfully on another server usingproxy_pass http://app:9000;
, but that is when nginx is running from inside the docker container:I forgot to try
proxy_pass http://listmonk_app:5870;
though. I just tried that and I got the same error that I get withproxy_pass http://app:5870;
.Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.