this post was submitted on 25 Nov 2023
8 points (78.6% liked)

Selfhosted

40246 readers
585 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

EDIT: It was a firewall issue. I disabled my firewall and it works.

https://listmonk.app/

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;
      }
}
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 11 months ago (1 children)

I wrote this a while back. Maybe it can help https://www.reddit.com/r/homelab/comments/arx2qe/tutorial_reverse_proxy_with_nginx/

502 usually means it's having a hard time hitting the service on the back end. Are you able to access listmonk directly without the reverse proxy? What is the URL I. The browser when you do that?

Is listmonk on the same server as nginx? Is nginx running in a container? If nginx is running in a container, 127.0.0.1 would try to load from inside the nginx container which isn't where listmonk is. Use the LAN IP address of the docker host listmonk is on instead of 127.0.0.1.

[–] [email protected] 1 points 11 months ago (1 children)

Thanks, I checked out your link. I think my most recent comment below answers some of your questions. https://lemmy.world/comment/5586470

Are you able to access listmonk directly without the reverse proxy? What is the URL I. The browser when you do that?

Besides the info I put in the OP, I'm not sure what else you're asking.

LAN IP address of the docker host

No idea what this is, so I looked it up https://www.howtogeek.com/devops/how-to-get-a-docker-containers-ip-address-from-the-host/ and ran docker ps then put the container ID at the end of this docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' docker-container-ID. It output an IP address which I used for proxy_pass http://docker-IP:5870;, restarted nginx, and nothing seems to have changed.

[–] [email protected] 1 points 11 months ago (1 children)

Not the docker container IP. The IP of the machine you are running docker itself on. Nginx is running in a container, it's not allowed to talk to the other docker container IP directly and it has a separate network stack from the listmonk container, so 127.0.0.1 only goes back to nginx.

Say your machine that you are running docker on is 192.168.0.67, the listmonk docker container is 172.16.0.89, and nginx container has an IP of 172.16.0.34.

Your nginx config would need the proxy to point to 192.168.0.67:5870.

Then make sure you don't have ufw or some similar firewall blocking the connection from nginx to listmonk.

[–] [email protected] 1 points 11 months ago* (last edited 11 months ago)

Nginx is running in a container

I don't think it is. On my other machine it's running in the docker container, but not this one.

Using serverIP:5870 has the same result as using listmonk.mysite.com:5870. It loads a broken page https://i.stack.imgur.com/gIy4A.jpg with broken links. IE: the URLs are http://localhost:9000/subscription/form.