brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: put Nginx Proxy Manager on a Docker network and stop publishing ports

Docker
~/tips/tip-nginxproxymanager-docker-network

docker network create scoobydoo

Lets Nginx Proxy Manager reach other containers by name, so they need no published host ports.

A lot of people proxy to 192.168.1.x:9000 and publish a port for every container. It works. It also leaves a pile of ports open on the host that nobody needs.

The docs recommend a shared Docker network instead. Create it once:

docker network create scoobydoo

Then add this block to the compose file of NPM and of every service you want to proxy:

networks:
  default:
    external: true
    name: scoobydoo

Now the upstream container needs no ports: entry at all. In the proxy host you type the container’s service name as hostname, for example portainer with port 9000. Docker’s own DNS does the rest. I like this because the only things reachable from outside are the ports NPM itself publishes.

One caveat from the docs: service names must be unique on that network. Two stacks that both call their database db will fight over the name. Give them distinct service names before you join them to the shared network.

It also makes the proxy host form easier to read. A name like portainer tells you more than an address does, and moving a container to another machine means changing one hostname instead of hunting for every place the old address was typed.

Further reading: Nginx Proxy Manager: Advanced Configuration, On this site: move the Nginx Proxy Manager admin page off port 81, On this site: pin the Nginx Proxy Manager image version, upgrade on purpose, On this site: Guide: put Nextcloud behind Nginx Proxy Manager with HTTPS and the right headers

Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link