Database passwords in a compose file end up in screenshots, forum posts and backups. NPM has a way around that.
Add __FILE to the end of a variable name and NPM reads the value from a file instead. The docs show it for the MariaDB setup:
environment:
DB_MYSQL_HOST: "db"
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD
secrets:
MYSQL_PWD:
file: ./.secrets/mysql_pwd.txt
The password lives in .secrets/mysql_pwd.txt, and the compose file only points to it. The database container supports the same trick: the linuxserver MariaDB image takes MYSQL_PASSWORD__FILE and MYSQL_ROOT_PASSWORD__FILE.
Caveat one: the secrets folder is now the thing to protect, so keep it out of git with a .gitignore line. Caveat two: if you leave the DB_MYSQL_* variables in, they take precedence over the SQLite ones, so you cannot mix the two. Remove them all if you go back to SQLite.
The same approach works for the PostgreSQL variables, since the docs describe the suffix as working on a variable name in general and show it on the database password. Test with a throwaway container first, because a wrong path to the secret file shows up as a database connection error.
Further reading: Nginx Proxy Manager: Advanced Configuration, Nginx Proxy Manager: Setup, On this site: an access list with a password can lock you out of the app behind it, On this site: rate limit your proxy hosts with http_top.conf and server_proxy.conf, On this site: Keep passwords out of your Docker Compose file
Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause