nginx-proxy-manager-Bash-API/README.md

102 lines
4.1 KiB
Markdown
Raw Normal View History

2024-07-10 14:23:30 +02:00
# Nginx Proxy Manager CLI Script
2024-07-10 21:15:14 +02:00
## Description
2024-07-10 14:23:30 +02:00
_by Erreur32_
2024-07-10 22:33:05 +02:00
🛠️ This BASH script allows you to manage Nginx Proxy Manager via the API.
2024-07-10 14:23:30 +02:00
2024-07-11 19:15:42 +02:00
🔑 Automatically generates and manages the tokens, ensuring their validity, so you don't have to worry about token expiration.
2024-07-10 14:26:46 +02:00
2024-07-12 13:11:23 +02:00
⚙️ Provides functionalities such as creating and deleting proxy hosts, managing users, displaying configurations, BACKUP! and more.
2024-07-10 14:17:48 +02:00
2024-07-12 13:11:23 +02:00
Ce script permet de gérer Nginx Proxy Manager via l'API. Il fournit des fonctionnalités telles que la création de hosts proxy, la gestion des utilisateurs, et l'affichage des configurations avec creation de BACKUP !
2024-07-10 21:15:14 +02:00
2024-07-11 18:25:09 +02:00
## Prerequisites
2024-07-10 21:15:14 +02:00
- `curl`
- `jq`
```bash
2024-07-10 22:44:33 +02:00
sudo apt-get install jq curl
2024-07-10 21:15:14 +02:00
```
2024-07-10 14:45:21 +02:00
2024-07-10 22:44:33 +02:00
## Installation
```
2024-07-11 12:39:16 +02:00
wget https://raw.githubusercontent.com/Erreur32/nginx-proxy-manager-API/main/nginx_proxy_manager_cli.sh
chmod +x nginx_proxy_manager_cli.sh
2024-07-10 22:44:33 +02:00
```
2024-07-10 14:45:21 +02:00
2024-07-11 18:27:04 +02:00
## Settings
2024-07-10 22:44:33 +02:00
Only edit these 3 variables:
2024-07-10 14:45:21 +02:00
```
2024-07-11 19:16:35 +02:00
## Nginx proxy IP address (your Nginx IP)
2024-07-10 20:48:13 +02:00
NGINX_IP="127.0.0.1"
2024-07-10 22:44:33 +02:00
## Existing user (user and password) on NPM
2024-07-10 20:48:13 +02:00
API_USER="existingUser@mail.com"
2024-07-10 14:45:21 +02:00
API_PASS="password"
```
2024-07-11 18:27:04 +02:00
## Usage
2024-07-10 14:17:48 +02:00
```bash
./nginx_proxy_manager_cli.sh [OPTIONS]
```
2024-07-11 18:27:04 +02:00
## Options
2024-07-10 14:17:48 +02:00
```tcl
2024-07-12 13:23:51 +02:00
Options:
-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)
-p FORWARD_PORT Port of the target server (required for creating/updating hosts)
-f FORWARD_SCHEME Scheme for forwarding (http/https, default: http)
-s SSL_FORCED Force SSL (true/false, default: false)
-c CACHING_ENABLED Enable caching (true/false, default: false)
-b BLOCK_EXPLOITS Block exploits (true/false, default: true)
-w ALLOW_WEBSOCKET_UPGRADE Allow WebSocket upgrade (true/false, default: true)
-h HTTP2_SUPPORT Support HTTP/2 (true/false, default: true)
-a ADVANCED_CONFIG Advanced configuration (block of configuration settings)
-e LETS_ENCRYPT_AGREE Accept Let's Encrypt (true/false, default: false)
-m LETS_ENCRYPT_EMAIL Email for Let's Encrypt (required if LETS_ENCRYPT_AGREE is true)
-n DNS_CHALLENGE DNS challenge (true/false, default: false)
-t TOKEN_EXPIRY Token expiry duration (default: 1y)
--create-user user pass Create a user with a username and password
--delete-user username Delete a user by username
--delete-host id Delete a proxy host by ID
--list-hosts List the names of all proxy hosts
--list-hosts-full List all proxy hosts with full details
--list-ssl-certificates List all SSL certificates
--list-users List all users
--search-host hostname Search for a proxy host by domain name
--enable-host id Enable a proxy host by ID
--disable-host id Disable a proxy host by ID
--check-token Check if the current token is valid
--backup Backup all configurations to a file
--help Display this help
2024-07-10 14:17:48 +02:00
```
2024-07-10 14:05:48 +02:00
2024-07-11 18:27:04 +02:00
## Examples
2024-07-10 14:17:48 +02:00
```bash
2024-07-12 13:23:51 +02:00
Usage:
./nginx_proxy_manager_cli.sh [OPTIONS]
Examples:
./nginx_proxy_manager_cli.sh -d example.com -i 192.168.1.10 -p 8080 -s true
./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 --list-hosts
./nginx_proxy_manager_cli.sh --backup
Advanced proxy tab example:
2024-07-12 13:26:49 +02:00
./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;'
2024-07-10 14:17:48 +02:00
```
2024-07-10 14:19:15 +02:00
2024-07-11 15:14:20 +02:00
![https://github.com/Erreur32/nginx-proxy-manager-API/blob/main/screen-nginx-proxy-script.png](https://github.com/Erreur32/nginx-proxy-manager-API/blob/main/screen-nginx-proxy-script.png)
2024-07-10 14:23:30 +02:00
2024-07-10 14:19:15 +02:00
## TODO:
2024-07-11 18:27:04 +02:00
- [x] add setting for ADVANCED configuration in `location / { ... }`
2024-07-12 13:11:23 +02:00
- [x] Add documentation on certain functions
2024-07-12 13:08:46 +02:00
- [x] ADD: a configuration function for Custom Locations
- [x] Backup / Export all settings from NPM
2024-07-11 18:50:35 +02:00
- [ ] Domain TLS check validity