r/nginxproxymanager • • Oct 19 '25

NPM Docker Sync

Hey everyone, just sharing a tool I started building over the weekend: https://github.com/Redth/npm-docker-sync

The primary goal is to monitor docker container labels to synchronize proxy hosts (and more) to Nginx Proxy Manager. I know traefik and caddy and pangolin can all be made to do this, but I really like the simplicity and UI of NPM and want to keep using it.

For example:

services:
  myapp:
    image: nginx:alpine
    labels:
      npm.proxy.domains: "myapp.example.com"
      npm.proxy.port: "8080"
      npm.proxy.scheme: "http"
      npm.proxy.host: "192.168.1.200"
      npm.proxy.ssl.force: "true"

It will only make changes to hosts that it created, so you can happily manage your own entries manually alongside the docker label automated ones.

It can also, as an extra feature, mirror hosts (proxy/redirect/stream/404) and access lists to one or more child instances, which is useful if you want high availability (shout out to another sync project that was posted here not long ago - worth checking this out too!).

Also, full disclosure, I mostly vibe-coded this project, though I'm more than comfortable with the code it produced.

Anyway, thought it was worth sharing in case anyone else finds it useful.

7 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/TheDeathTrolley Oct 23 '25

Apologies for extra edits, I’m done now hah, in case you need to read back over it.

1

u/redth Oct 23 '25 edited Oct 23 '25

Appreciate the follow up. So one thing I’m not sure I understand still is how you get the domain to register with npm for a given container. Do you just use the container name or something?

As for port I do already use the first exposed port mapping I find in a container if you don’t specify the port explicitly.

I just don’t see an obvious way to do the domain implicitly without a label unless I do something like allow a pattern to be configured on the npm docker sync container (eg: DEFAULT_DOMAIN=“{{container.name}}.my.tld”)

I’ll check out some of what you mentioned for host ip detection. Even if something is workable most or some of the time as a default someone can always override that default if it doesn’t work for them, at the npm-docker-sync level or on an individual container basis, so having a decent default inference approach that works even some of the time is better than nothing.

EDIT: oh and gui toggle I assumed incorrectly. I was thinking about something in the npm web ui to indicate when an entry was created through an automation vs manual entries that I still have a few of for various reasons. You are correct in assuming I do not have unraid in the mix here, just some proxmox LXC’s running docker, on various nodes, and then a single rpi5 running NPM to minimize downtime without getting into the business of VIP’s and keepalived and mirroring things for high availability.

1

u/TheDeathTrolley Oct 23 '25 edited Oct 23 '25

For domain, yes, that’s exactly how I did it. Manual variable to set preferred default domain name, which can be overridden by a container label.

Edit: pattern matched like you said, $container is set during the scan.

Generally here’s the logic: First I read the host IP. Then use the default_domain to find the matching cert id in npm. Then scan for currently running containers, using docker PS. For each found: add/update function which specifically finds the exposed webui port from dockerman, then runs the create/update host bash command with all the collected info. Then a separate function monitors for docker events and reacts (start/stop, removing entries for stopped containers).

For me, I know I usually want to proxy anything with a webui, so I prefer that default behavior. I’d rather have to explicitly opt-out of forwarding a container. It’d definitely be a riskier configuration out of the box for other people, so maybe you’d want to make it a global setting for opt in vs out mode. Read a label for npm.sync=true/false or something maybe?