Python Script to manipulate Nginx Proxy Manager reverse proxies reddit / selfhosted ---------------------------------------------------------------------- IllustratorVarious · 2023-10-09 11:18 I made a simple python script to make it simpler to manage reverse proxies. ​ \[GitHub\]([https://github.com/yusing/nginx-proxy- cli](https://github.com/yusing/nginx-proxy-cli)) ​ (\*\*Caution\*\*) \*I have no responsibility when causing bugs/conflicts using the script, use on your own risk. But feel free to create "issues" or feature requests on GitHub.\* ​ What you may want to do: ​ Rename it to something like \`nginx\_proxy\_cli\` and move it to \`$HOME/.local/bin\` and then \`chmod +x $HOME/.local/bin/nginx\_proxy\_cli\`. ​ Available commands: ​ \* list-user: List all users (no args) \* list-cert: List all certificates (no args) \* list-proxy: List all proxies (no args) \* add-proxy: Add a new proxy (with optional \`--dry-run\` to preview changes) \* delete-proxy: Delete a proxy (no args) ​ Environment Variables: ​ \* \`NPM\_URL\` (required): URL that points to Nginx Proxy Manager \* \`NPM\_AUTH\_TOKEN\` (optional): The "Bearer XXX" token for making API request, will ask for login with email and password if not provided. \* \`HOME\` (required): By default, auth credentials with be saved in $HOME/.local/nginx\\\_proxy.json ---------------------------------------------------------------------- ElevenNotes · 2023-10-09 11:25 or, just a thought, simply use nginx with config files. ---------------------------------------------------------------------- IllustratorVarious · 2023-10-09 11:29 But, just my thoughts, it’s a disaster when you have like 20+ proxy hosts. ---------------------------------------------------------------------- mtrueman · 2023-10-09 11:38 I prefer nginx proxy manager, ---------------------------------------------------------------------- ElevenNotes · 2023-10-09 12:19 No. You can include files. You need only one file for SSL settings, one for general proxy headers and so on. ---------------------------------------------------------------------- IllustratorVarious · 2023-10-09 12:22 This script sends API calls to nginx proxy manager web ---------------------------------------------------------------------- JumpingCoconutMonkey · 2023-10-09 13:11 I guess I don't understand the use case here. NPM does all of this in the gui and it isn't complicated. If you want to deal with command lines and files, would you not be better off with plain old nginx? ---------------------------------------------------------------------- IllustratorVarious · 2023-10-09 13:48 It saved some time that it only takes a few seconds to create a new proxy. Details like domain name, target host, target port is asked separately instead of taking as argument. Also a default location / {…} thing is generated from your requirements. ---------------------------------------------------------------------- IllustratorVarious · 2023-10-09 13:50 Maybe when you have cd-ed into the nginx directory, I have already added a new proxy with my script. ---------------------------------------------------------------------- ElevenNotes · 2023-10-09 14:15 Oh don't worry. My nginx is all managed via a central API, after all I manage a few dozen nginx proxies. But for the average selfhoster a few config files are pretty easy to manage, and you can even rollback via git if you made some errors. ---------------------------------------------------------------------- JumpingCoconutMonkey · 2023-10-09 14:25 If it works for you, you did great. I also frequently add or change entries in NPM and it doesn't take a lot of effort to do so using NPM's gui. ---------------------------------------------------------------------- mb2m · 2023-10-09 14:38 Why not use vanilla nginx and configure your upstreams and stuff using something like Ansible’s templates or something. ---------------------------------------------------------------------- sk1nT7 · 2023-10-09 15:53 Why are people using NPM? Because it provides a GUI and is simplistic. The end user can be non-technical to configure a proxy host. Why are people using plain nginx? Because they are technically savvy and enjoy the full feature set and control by editing config files. They most often use the terminal anyway, so they feel confident editing config files. Now, you created a Python script, which must be run from the CLI terminal. Users of NPM usually picked NPM as they do not want to use the terminal. They wanted a GUI to click stuff to make things work. So be aware that not many people will see a benefit in your script. However, thanks for sharing. If it works for you and reduces effort, that's brilliant! ---------------------------------------------------------------------- ASouthernBoy · 2023-10-09 21:37 What tool do you use for central mgmt? ---------------------------------------------------------------------- Spuxilet · 2023-10-09 22:29 Just use traefik and configure reverse proxies inside docker compose file labels. On the plus side when service goes down, reverse proxy will also go down. It's made for docker environment so why not use it? ---------------------------------------------------------------------- ElevenNotes · 2023-10-10 05:43 My own developed one. ---------------------------------------------------------------------- IllustratorVarious · 2023-10-10 16:23 Traefik does not work in my case, and I don’t wanna waste time trying to fix that. ---------------------------------------------------------------------- IllustratorVarious · 2023-10-10 16:32 I see your point and kinda agree with you. But when they play with docker they must play with terminal right? I’m just taking the advantages of both by making this script. No tech knowledge required, just type what it prompted.