NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.59k stars 2.62k forks source link

Ability to inject rules on first startup? #1575

Closed mckernanin closed 2 years ago

mckernanin commented 2 years ago

Is your feature request related to a problem? Please describe. I'm working on adding a simple docker-compose setup to an open source project, have previously used Traefik but NPM is very user friendly and for our use case, a better fit for our users. I'm trying to preconfigure everything that I can. I would like a way to inject some starter proxy routes into NPM.

Describe the solution you'd like Very open to the actual solution. Could be an INIT SQL file for the DB, could be ability to import/export routes from the UI.

Describe alternatives you've considered I'll investigate running an init container to setup the database on initial setup

Additional context

mckernanin commented 2 years ago

I looked up the base container for maria, and it does support init sql from a directory: https://github.com/yobasystems/alpine-mariadb/blob/5fa698243188d5abc879e3cc071578aec063b7ef/alpine-mariadb-amd64/files/run.sh?_pjax=%23js-repo-pjax-container%3Afirst-of-type%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%3Afirst-of-type%2C%20%5Bdata-pjax-container%5D%3Afirst-of-type#L74

chaptergy commented 2 years ago

Unfortunately there is currently no built-in way to do this. Populating the database is not enough, since the db is used to display the data in the admin ui, but changes in the db will not automatically be propagated to nginx. So when the api receives a request, the nginx config is generated and the db is updated, but the nginx and the db are not connected.

Here is how I would suggest doing this: Use the SQLite file instead of an external database and provide a pre-set-up SQLite file and some nginx config files to set up what you need, which can then be copied into the container using docker cp.

mckernanin commented 2 years ago

Ok thanks. Going to close this, I ended up deciding to just provide a walkthrough on how to setup NPM. If I really wanted it to be config driven, I'd go back to traefik