this post was submitted on 22 Jul 2025
38 points (95.2% liked)

Selfhosted

49703 readers
235 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 2 years ago
MODERATORS
 

I'm trying to set up local DNS using Pi-hole.

I have successfully set up Pi-hole and added a local DNS record local.com, pointing it to the server running the Pi-hole container 192.168.0.101.

Then I set up the Audiobookshelf container using the guide from Audiobookshelf, where I set up Nginx Proxy Manager with the following compose file:

services:
  nginx-proxy-manager:
    image: docker.io/jc21/nginx-proxy-manager:latest
    container_name: nginx-proxy-manager
    ports:
      - 80:80
      - 443:443
      - 81:81
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    restart: unless-stopped

And Audiobookshelf with the following compose file:

services:
  audiobookshelf:
    image: ghcr.io/advplyr/audiobookshelf:latest
    container_name: audiobookshelf
    volumes:
      - ./audiobooks:/audiobooks
      - ./podcasts:/podcasts
      - ./metadata:/metadata
      - ./config:/config
    restart: unless-stopped
networks:
  nginx:
    name: nginx-proxy-manager_default
    external: true

I did not specify a port, hoping that Nginx could manage it.

Then I set up Nginx Proxy Manager following the guide from Audiobookshelf by adding a proxy host. ~~Trying to resolve audiobookshelf.local.com to~~ I simply followed the guide and wasn’t sure why the “Forward Hostname / IP” should be the container name audiobookshelf.

I also created a self-signed certificate.

But I cannot access https://audiobookshelf.local.com/ or http://audiobookshelf.local.com/ (it automatically forwards to HTTPS).


I tried adding a local DNS record:
audiobookshelf.local.com192.168.0.101 in Pi-hole.
Now, when I access audiobookshelf.local.com, the site shows:
502 Bad Gateway – openresty


I think the problem lies in the Docker network setup. I suspect the Audiobookshelf Docker container is not communicating with Nginx.


Would appreciate any help!

you are viewing a single comment's thread
view the rest of the comments
[–] Malasaur@sh.itjust.works 3 points 1 day ago (3 children)

I'm pretty sure you have to specify a different port. Audiobookshelf uses port 80 by default - which is already taken by NPM - and since you're not mapping it to any other port those services will conflict.

Map the port to something easy to remember in the compose file. Not only is it required in your setup but it is good practice. If you have to manage a lot of services, it is hard to keep track of all the ports they use if you keep them on their default values. I personally chose a port range (like 12300 -> 12399) and map all of my services respectively (Komodo to 12300, Authentik to 12301, etc.).

Also remember to update the port in your NPM config.

TL;DR: Audiobookshelf's default port is 80, which conflicts with NPM. Change it.

[–] clmbmb@lemmy.dbzer0.com 2 points 1 day ago

There's no conflict regarding ports. Each container can have the same ports open. You're thinking about the host network here, but it's not the case.

[–] BigDogDave@lemmy.world 3 points 1 day ago (1 children)

If the port isn't being explicitly exposed then it won't expose by default. I have my containers set up in a similar way where nginx has it's own network and I attach any containers I want to proxy to the same network. On most cases I'm able to remove the ports section from config and point nginx at the name of the container, and the container's default http port. The way OP originally configured this should be fine IF nginx and audiobookshelf are on the same docker network.

[–] Malasaur@sh.itjust.works 1 points 1 day ago

I honestly didn't know that. I personally just configure a specific port for each stack and have NPM forward it directly without configuring any network.

I just noticed OP did configure a network, but tbh I don't know how they work exactly and gave recommendations on what I knew.

If using networks is the standard way or OP feels better off that way then I'll leave them to it

[–] happeningtofry99158@lemmy.world 2 points 1 day ago (2 children)

thank you!

I have added

    ports:
      - 13378:80

in audiobookshelf docker compose and changed npm settings

But it still gives me the same 502 Bad Gateway error.

[–] MysteriousSophon21@lemmy.world 1 points 21 hours ago (1 children)

You're missing the networks section in your audiobookshelf service definition - add networks: [nginx] to your audiobookshelf service to actually connect it to the network (just defining the network at the bottom doesn't automatically attach your service to it, which is why npm can't reach it and gives you that 502 error), and if you're an audiobook fan you might wanna check out the soundleaf app for ios which works great with audiobookshelf.

[–] happeningtofry99158@lemmy.world 1 points 6 hours ago

thank you! this works!

[–] Malasaur@sh.itjust.works 1 points 1 day ago (1 children)

I've just noticed: you've set your forward hostname/IP to audiobookshelf. That should either be your PC's IP address (if you've set up a static one in your router's panel) or its hostname. Unless you've named your PC audiobookshelf it still won't work.

[–] clmbmb@lemmy.dbzer0.com 2 points 1 day ago

This is about addressing the containers in docker. It has nothing to do with the local network.