mirror of
https://github.com/Erreur32/nginx-proxy-manager-Bash-API.git
synced 2025-01-15 08:11:54 +01:00
Compare commits
16 commits
450d490e16
...
95b32880d1
Author | SHA1 | Date | |
---|---|---|---|
95b32880d1 | |||
542219ada0 | |||
35d0b2f355 | |||
e14bb2ed50 | |||
8520b05c60 | |||
7406e774e6 | |||
fbc9b0ee91 | |||
9b82091846 | |||
4e61409927 | |||
617572a25f | |||
14fd55f95a | |||
9491f64577 | |||
ca8cc272dd | |||
77b09b3742 | |||
94bb96bc48 | |||
dfc72f1999 |
2 changed files with 853 additions and 364 deletions
91
README.md
Normal file → Executable file
91
README.md
Normal file → Executable file
|
@ -13,6 +13,11 @@
|
||||||
9. [Screens](#screens)
|
9. [Screens](#screens)
|
||||||
10. [TODO](#todo)
|
10. [TODO](#todo)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> Sometime Global RESTORE (--restore) function may not works for HOST only (fix will come)
|
||||||
|
>
|
||||||
|
> Single RESTORE (--restore-id , add host one by one) should work well.
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
🛠️ This BASH script enables the management of ![Nginx Proxy Manager](https://github.com/NginxProxyManager/nginx-proxy-manager?utm_source=nginx-proxy-manager) through its **API**.
|
🛠️ This BASH script enables the management of ![Nginx Proxy Manager](https://github.com/NginxProxyManager/nginx-proxy-manager?utm_source=nginx-proxy-manager) through its **API**.
|
||||||
|
@ -45,15 +50,22 @@ wget https://raw.githubusercontent.com/Erreur32/nginx-proxy-manager-API/main/ngi
|
||||||
chmod +x nginx_proxy_manager_cli.sh
|
chmod +x nginx_proxy_manager_cli.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
## Settings
|
|
||||||
Only edit these 3 variables:
|
|
||||||
|
|
||||||
```
|
> [!IMPORTANT]
|
||||||
|
> With new version 2.0.0 some commands are changed.
|
||||||
|
>
|
||||||
|
## Settings
|
||||||
|
Only edit these 4 variables:
|
||||||
|
|
||||||
|
```bash
|
||||||
## Nginx proxy IP address (your Nginx IP)
|
## Nginx proxy IP address (your Nginx IP)
|
||||||
NGINX_IP="127.0.0.1"
|
NGINX_IP="127.0.0.1"
|
||||||
## Existing user (user and password) on NPM
|
## Existing user (user and password) on NPM
|
||||||
API_USER="existingUser@mail.com"
|
API_USER="existingUser@mail.com"
|
||||||
API_PASS="password"
|
API_PASS="password"
|
||||||
|
# Path to store .txt files and Backups
|
||||||
|
BASE_DIR="/path/nginx_proxy_script/data"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -63,7 +75,8 @@ API_PASS="password"
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
```tcl
|
```tcl
|
||||||
🌐 Host proxy Domain creation:
|
|
||||||
|
🌐 Host proxy creation:
|
||||||
-d DOMAIN_NAMES Domain name (required for creating/updating hosts)
|
-d DOMAIN_NAMES Domain name (required for creating/updating hosts)
|
||||||
-i FORWARD_HOST IP address or domain name of the target server (required for creating/updating hosts)
|
-i FORWARD_HOST IP address or domain name of the target server (required for creating/updating hosts)
|
||||||
-p FORWARD_PORT Port of the target server (required for creating/updating hosts)
|
-p FORWARD_PORT Port of the target server (required for creating/updating hosts)
|
||||||
|
@ -71,21 +84,22 @@ API_PASS="password"
|
||||||
-c CACHING_ENABLED Enable caching (true/false, default: false)
|
-c CACHING_ENABLED Enable caching (true/false, default: false)
|
||||||
-b BLOCK_EXPLOITS Block exploits (true/false, default: true)
|
-b BLOCK_EXPLOITS Block exploits (true/false, default: true)
|
||||||
-w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: true)
|
-w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: true)
|
||||||
|
-l CUSTOM_LOCATIONS Custom locations (JSON array of location objects)
|
||||||
-a ADVANCED_CONFIG Advanced configuration (block of configuration settings)
|
-a ADVANCED_CONFIG Advanced configuration (block of configuration settings)
|
||||||
|
|
||||||
📦 Backup and Restore:
|
📦 Backup and Restore:
|
||||||
--host-backup Backup all configurations to a file
|
--backup Backup all configurations to a file
|
||||||
--host-backup-id id Backup a single host configuration and its certificate (if exists)
|
--backup-id id Backup a single host configuration and its certificate (if exists)
|
||||||
--host-restore Restore configurations from a backup file
|
--restore Restore configurations from a backup file
|
||||||
--host-restore-id id Restore a single host configuration and its certificate (if exists)
|
--restore-id id Restore a single host configuration and its certificate (if exists)
|
||||||
|
|
||||||
🔧 Miscellaneous:
|
🔧 Miscellaneous:
|
||||||
--host-check-token Check if the current token is valid
|
--check-token Check if the current token is valid
|
||||||
--host-create-user user pass email Create a user with a username, password and email
|
--create-user user pass email Create a user with a username, password and email
|
||||||
--host-delete-user username Delete a user by username
|
--delete-user username Delete a user by username
|
||||||
--host-delete id Delete a proxy host by ID
|
--host-delete id Delete a proxy host by ID
|
||||||
--host-show id Show full details for a specific host by ID
|
--host-show id Show full details for a specific host by ID
|
||||||
--host-show-default Show default settings for creating hosts
|
--show-default Show default settings for creating hosts
|
||||||
--host-list List the names of all proxy hosts
|
--host-list List the names of all proxy hosts
|
||||||
--host-list-full List all proxy hosts with full details
|
--host-list-full List all proxy hosts with full details
|
||||||
--host-list-ssl-certificates List all SSL certificates
|
--host-list-ssl-certificates List all SSL certificates
|
||||||
|
@ -93,59 +107,75 @@ API_PASS="password"
|
||||||
--host-search hostname Search for a proxy host by domain name
|
--host-search hostname Search for a proxy host by domain name
|
||||||
--host-enable id Enable a proxy host by ID
|
--host-enable id Enable a proxy host by ID
|
||||||
--host-disable id Disable a proxy host by ID
|
--host-disable id Disable a proxy host by ID
|
||||||
--host-ssl-enable id Enable SSL, HTTP/2, and HSTS for a proxy host (don't need to generate a custom cert.)
|
--host-ssl-enable id Enable SSL, HTTP/2, and HSTS for a proxy host
|
||||||
--host-ssl-disable id Disable SSL, HTTP/2, and HSTS for a proxy host
|
--host-ssl-disable id Disable SSL, HTTP/2, and HSTS for a proxy host
|
||||||
--host-generate-cert domain email [--custom] Generate a Let's Encrypt or Custom certificate for the given domain and email
|
--generate-cert domain email [--custom] Generate a Let's Encrypt or Custom certificate for the given domain and email
|
||||||
--host-help Display this help
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
📦 Backup First !
|
📦 Backup First !
|
||||||
./nginx_proxy_manager_cli.sh --backup
|
./nginx_proxy_manager_cli.sh --backup
|
||||||
|
|
||||||
|
🌐 Host Creation:
|
||||||
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 (check default values below)
|
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 (check default values below)
|
||||||
|
./nginx_proxy_manager_cli.sh --info
|
||||||
./nginx_proxy_manager_cli.sh --show-default
|
./nginx_proxy_manager_cli.sh --show-default
|
||||||
./nginx_proxy_manager_cli.sh --create-user newuser password123 user@example.com
|
./nginx_proxy_manager_cli.sh --create-user newuser password123 user@example.com
|
||||||
./nginx_proxy_manager_cli.sh --delete-user 'username'
|
./nginx_proxy_manager_cli.sh --delete-user 'username'
|
||||||
./nginx_proxy_manager_cli.sh --list-hosts
|
./nginx_proxy_manager_cli.sh --host-list
|
||||||
./nginx_proxy_manager_cli.sh --ssl-host-enable 10
|
./nginx_proxy_manager_cli.sh --host-ssl-enable 10
|
||||||
./nginx_proxy_manager_cli.sh --generate-cert example.com user@example.com --custom (for custom certificat)
|
|
||||||
|
|
||||||
🔧 Advanced proxy tab example:
|
🔧 Advanced Example:
|
||||||
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'
|
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'
|
||||||
|
|
||||||
|
🛡️ Custom Certificate:
|
||||||
|
./nginx_proxy_manager_cli.sh --generate-cert example.com user@example.com --custom
|
||||||
|
|
||||||
|
🛡️ Custom locations:
|
||||||
|
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]'
|
||||||
|
|
||||||
🔖 Full options:
|
🔖 Full options:
|
||||||
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -f https -c true -b true -w true -a 'proxy_set_header X-Real-IP $remote_addr;' -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]'
|
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -f https -c true -b true -w true -a 'proxy_set_header X-Real-IP $remote_addr;' -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]'
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Enable SSL for the Host:
|
#### SSL
|
||||||
|
Enable SSL for the Host:
|
||||||
|
|
||||||
Assuming the host ID is *10*, you would enable SSL for the host as follows:
|
Assuming the host ID is *10*, you would enable SSL for the host as follows:
|
||||||
|
|
||||||
./nginx_proxy_manager_cli.sh --ssl-host-enable 10
|
./nginx_proxy_manager_cli.sh --host-ssl-enable 10
|
||||||
|
|
||||||
#### Verifying the Configuration
|
##### Verifying the Configuration
|
||||||
|
|
||||||
After running the above commands, you can verify the SSL configuration by checking the details of the proxy host.
|
After running the above commands, you can verify the SSL configuration by checking the details of the proxy host.
|
||||||
|
|
||||||
./nginx_proxy_manager_cli.sh --show-host 10
|
./nginx_proxy_manager_cli.sh --host-show 10
|
||||||
|
|
||||||
This command will show the full details of the proxy host with ID *10*, including whether SSL is enabled.
|
This command will show the full details of the proxy host with ID *10*, including whether SSL is enabled.
|
||||||
|
|
||||||
By following these steps, you can enable SSL for your proxy host for the first time using Let's Encrypt.
|
By following these steps, you can enable SSL for your proxy host for the first time using Let's Encrypt.
|
||||||
|
|
||||||
You should now see the parameters activated:
|
##### Better way to check if SSL is active
|
||||||
- "ssl_forced": 1,
|
|
||||||
- "letsencrypt_agree": true,
|
|
||||||
- "http2_support": 1
|
|
||||||
|
|
||||||
|
./nginx_proxy_manager_cli.sh --host-list
|
||||||
|
|
||||||
|
👉 List of proxy hosts (simple)
|
||||||
|
ID Domain Status SSL
|
||||||
|
1 toto.fun disable ✘
|
||||||
|
2 titi.fun disable ✅
|
||||||
|
3 tutu.fun enabled ✅
|
||||||
|
|
||||||
|
|
||||||
|
You should now see the parameters activated ✅
|
||||||
|
|
||||||
|
##### Host proxy info
|
||||||
```
|
```
|
||||||
./nginx_proxy_manager_cli_.sh --show-host 10
|
./nginx_proxy_manager_cli_.sh --host-show 10
|
||||||
|
|
||||||
✅ Nginx url: http://127.0.0.1:81/api
|
✅ Nginx url: http://127.0.0.1:81/api
|
||||||
✅ The token is valid. Expiry: 2025-07-12T08:14:58.521Z
|
✅ The token is valid. Expiry: 2025-07-12T08:14:58.521Z
|
||||||
|
@ -207,3 +237,4 @@ You should now see the parameters activated:
|
||||||
- [x] Export all settings to NPM
|
- [x] Export all settings to NPM
|
||||||
- [ ] Domain TLS check validity
|
- [ ] Domain TLS check validity
|
||||||
- [ ] Better Error Handeling
|
- [ ] Better Error Handeling
|
||||||
|
- [ ] Restore Function need to be optimized
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue