Skip to content

Commit 9f4fa85

Browse files
committed
feat: Fix multiple GitHub issues and improve argument parsing
🐛 Bug Fixes: - Fix Issue #24: Add support for --allow, --deny, --users options in access-list-create and access-list-update - Fix Issue #23: Fix --websocket and --cache options not being respected in host creation - Fix Issue #22: Add support for -l (custom-locations) and -a (advanced-config) options 🔧 Technical Improvements: - Fix variable naming consistency in argument parsing - Correct default values for boolean options - Add proper error handling and validation for all new options - Update help messages and documentation 📚 Documentation Updates: - Update CHANGELOG.md with detailed fix descriptions - Update README.md version to 3.0.5 - Add comprehensive usage examples for all fixed options - Improve error messages with helpful examples ✅ All documented options now work correctly: - Access list management with IP restrictions and user authentication - Proxy host creation with caching and websocket support - Custom locations and advanced nginx configuration Resolves: #22, #23, #24 Version: 3.0.5
1 parent 8b57bc5 commit 9f4fa85

File tree

3 files changed

+257
-22
lines changed

3 files changed

+257
-22
lines changed

CHANGELOG.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,89 @@
1-
# Changelog
1+
## [3.0.5] - 2025-01-20e changes to the npm-api.sh script will be documented in this file.
22

3-
All notable changes to the npm-api.sh script will be documented in this file.
4-
5-
## [3.0.2] - 2025-01-20
3+
## [3.0.5] - 2025-01-20
64

75
### 🐛 Bug Fixes
86

7+
- **Fixed `-l` and `-a` options being ignored in host creation** ([Issue #22](https://github.com/Erreur32/nginx-proxy-manager-Bash-API/issues/22))
8+
- **Issue**: The commands `./npm-api.sh --host-create example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr;'` and `./npm-api.sh --host-create example.com -i 192.168.1.10 -p 8080 -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]'` were showing "Unknown option ignored" warnings
9+
- **Root Cause**: The options `-l` (custom_locations) and `-a` (advanced_config) were documented in help text but not implemented in the argument parsing for `--host-create`
10+
- **Solution**:
11+
- Added support for `-l|--custom-locations` option in argument parsing
12+
- Added support for `-a|--advanced-config` option in argument parsing
13+
- Updated help messages to include these options in the optional parameters list
14+
- Added proper error handling and validation for both options
15+
- **Technical Details**:
16+
- Added `-l|--custom-locations` case in argument parsing with JSON validation
17+
- Added `-a|--advanced-config` case in argument parsing with string validation
18+
- Updated all help message sections to include the new options
19+
- Added example usage in error messages for better user guidance
20+
- **Usage Examples**:
21+
```bash
22+
# Create host with custom locations
23+
./npm-api.sh --host-create example.com -i 192.168.1.10 -p 8080 -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]'
24+
25+
# Create host with advanced configuration
26+
./npm-api.sh --host-create example.com -i 192.168.1.10 -p 8080 -a 'proxy_set_header X-Real-IP $remote_addr;'
27+
28+
# Create host with both custom locations and advanced config
29+
./npm-api.sh --host-create example.com -i 192.168.1.10 -p 8080 -l '[{"path":"/api","forward_host":"192.168.1.11","forward_port":8081}]' -a 'proxy_set_header X-Real-IP $remote_addr;'
30+
```
31+
32+
- **Fixed `--websocket` and `--cache` options not being respected in host creation** ([Issue #23](https://github.com/Erreur32/nginx-proxy-manager-Bash-API/issues/23))
33+
- **Issue**: The commands `./npm-api.sh --host-create example.com -i 192.168.1.100 -p 8081 --cache true --websocket true` were not enabling caching and websocket support in NPM
34+
- **Root Cause**:
35+
- Variable naming mismatch in argument parsing (`CACHE_ENABLED` vs `CACHING_ENABLED`, `WEBSOCKET_SUPPORT` vs `ALLOW_WEBSOCKET_UPGRADE`)
36+
- Incorrect default value for `ALLOW_WEBSOCKET_UPGRADE` (was `1` instead of `false`)
37+
- **Solution**:
38+
- Fixed variable names in argument parsing to match the variables used in the JSON payload
39+
- Corrected default value for `ALLOW_WEBSOCKET_UPGRADE` to `false`
40+
- Updated function call to use correct variable names
41+
- **Technical Details**:
42+
- Changed `cache) CACHE_ENABLED="$2"` to `cache) CACHING_ENABLED="$2"`
43+
- Changed `websocket) WEBSOCKET_SUPPORT="$2"` to `websocket) ALLOW_WEBSOCKET_UPGRADE="$2"`
44+
- Updated function call parameters to use correct variable names
45+
- Fixed default value: `ALLOW_WEBSOCKET_UPGRADE=1``ALLOW_WEBSOCKET_UPGRADE=false`
46+
- **Usage Examples**:
47+
```bash
48+
# Create host with caching enabled
49+
./npm-api.sh --host-create example.com -i 192.168.1.100 -p 8081 --cache true
50+
51+
# Create host with websocket support enabled
52+
./npm-api.sh --host-create example.com -i 192.168.1.100 -p 8081 --websocket true
53+
54+
# Create host with both caching and websocket support
55+
./npm-api.sh --host-create example.com -i 192.168.1.100 -p 8081 --cache true --websocket true
56+
```
57+
58+
- **Fixed `--allow` and `--deny` options not working in access-list commands** ([Issue #24](https://github.com/Erreur32/nginx-proxy-manager-Bash-API/issues/24))
59+
- **Issue**: The commands `./npm-api.sh --access-list-create "test" --allow "172.0.0.0/8"` and `./npm-api.sh --access-list-update 6 --allow "172.0.0.0/8"` were failing with "Unknown option --allow" error
60+
- **Root Cause**: The `--allow` and `--deny` options were documented in help text but not implemented in the actual functions
61+
- **Solution**:
62+
- Added full support for `--allow` and `--deny` options in `access_list_create()` function
63+
- Added full support for `--allow`, `--deny`, and `--users` options in `access_list_update()` function
64+
- Implemented comma-separated value parsing for multiple IPs/users
65+
- Added proper error handling and validation for all new options
66+
- **Technical Details**:
67+
- Added `--allow` option processing with comma-separated IP support
68+
- Added `--deny` option processing with comma-separated IP support
69+
- Added `--users` option processing with password prompts for each user
70+
- Updated help messages to include all available options
71+
- Maintained backward compatibility with existing `--access allow|deny <ip>` syntax
72+
- **Usage Examples**:
73+
```bash
74+
# Create access list with allow rules
75+
./npm-api.sh --access-list-create "office" --allow "192.168.1.0/24,10.0.0.0/8"
76+
77+
# Create access list with deny rules
78+
./npm-api.sh --access-list-create "secure" --deny "192.168.1.100,10.0.0.50"
79+
80+
# Update access list with new allow rules
81+
./npm-api.sh --access-list-update 6 --allow "172.0.0.0/8"
82+
83+
# Create access list with users and IP rules
84+
./npm-api.sh --access-list-create "full_config" --users "admin1,admin2" --allow "10.0.0.0/8" --deny "10.0.0.50"
85+
```
86+
987
- **Fixed `--access-list-update` command not working with arguments**
1088
- **Issue**: The command `./npm-api.sh --access-list-update 123 --name "new_name"` was failing with "Unknown option: 123" error
1189
- **Root Cause**: The argument parsing for `--access-list-update` was not properly capturing the access list ID and subsequent arguments

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Stargazers][stars-shield]][stars]
77

88

9-
# Nginx Proxy Manager CLI Script V3.0.2 🚀
9+
# Nginx Proxy Manager CLI Script V3.0.5 🚀
1010

1111
## Table of Contents
1212

0 commit comments

Comments
 (0)