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: Nginx Proxy Manager in Docker loads your own nginx snippets from /data/nginx/custom

Docker
~/tips/tip-docker-npm-custom-nginx-snippets

docker compose restart npm

Add global nginx settings to Nginx Proxy Manager that survive updates.

The Advanced tab of a proxy host is fine for one site. For a setting that belongs in nginx’s main config, such as a rate limit zone, Nginx Proxy Manager reads optional snippet files from /data/nginx/custom.

# on the host, in the folder mounted as /data
mkdir -p ./data/nginx/custom
echo 'limit_req_zone $binary_remote_addr zone=perip:10m rate=10r/s;' \
  > ./data/nginx/custom/http_top.conf
docker compose restart npm

The docs list which file is loaded where. http_top.conf and http.conf go at the start and end of the main http block, server_proxy.conf at the end of every proxy host’s server block, and there are matching files for redirection hosts, 404 hosts and streams, plus root_top.conf, root.conf and events.conf.

Because the files live in the data volume, they survive image updates, unlike edits made inside the container. The example defines a rate limit zone once; a single proxy host can then use it with limit_req zone=perip burst=20; in its Advanced tab. I find server_proxy.conf useful too, for headers or timeouts that every proxied app should get.

A typo in a snippet breaks nginx for all hosts at once, not just one. After a change I would look at docker compose logs npm for nginx errors before closing the terminal. Settings that already exist in NPM’s own config cannot be set twice; nginx refuses duplicate directives in the same block, so pick the file whose position avoids the clash.

Further reading: Nginx Proxy Manager: Advanced configuration

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