Open diegocade1 opened 5 months ago
so is this because the API is "unfinished", or just has a bug in this type of configuration ? been trying to find more info on NPM's API, but there doesn't actually seem to be any official Docs on it ? ..
i found this, https://documenter.getpostman.com/view/4475423/2s93mBvyLZ#be0769e8-9cd7-4a74-a075-d56c23fd3351 does seem to have most of the API commands, listed, but not all ..
and also found this,
https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1808
showing you can use address npm-admin-ui:81/api/schema
to get a list
but this too doesn't actually seem like a full working list ? ...
but it seems this post maybe the best ? .. https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1790 which links to this https://github.com/NginxProxyManager/nginx-proxy-manager/tree/develop/backend/routes/api
so going by this, im going to presume the API feature is still being formed, would be perfect if it did have just a few more bugs fixed, and features fully formed, like the Access List control for one !..
TL;DR;
looking at your code you supplied,
you have "items": [],
within the "payload"
which i believe is not needed/understood, so its given that odd error....
thought i would follow this up, i also posted within this "discussion" post here .. https://github.com/NginxProxyManager/nginx-proxy-manager/discussions/3195
as i DID NEARLY get this working, but it will only "re-create" the list, and will not "add" to to the existing list. did you get any further with your setup ?
curl -X PUT -H "Content-Type: application/json; charset=UTF-8" -H "Authorization: Bearer eyJhbGciOi...." -d '{ "name": "AccessListName", "satisfy_any": 0, "pass_auth": 0, "clients": [ { "address": "192.168.178.96", "directive": "allow" } ] }' http://192.168.1.5:81/api/nginx/access-lists/2
this works, but it SHOUD add to the existing list, but it re-creates it instead :( i found the reason why, and explained here https://github.com/NginxProxyManager/nginx-proxy-manager/discussions/3195#discussioncomment-8972116 just in case this comes up on someones search .,..
Checklist
jc21/nginx-proxy-manager:latest
docker image?Describe the bug
When trying to add an Access List through the api (the list has aprx 1512 entries of IPs)
Nginx Proxy Manager Version
To Reproduce Steps to reproduce the behavior:
def add_access_list(name: str, token: str, existing_rule_id: str, *clients: Access_Rule_Client) -> int: payload = { "name" : name, "satisfy_any" : True, "pass_auth" : False, "items": [], "clients": [{'address': rule.address, 'directive': rule.directive} for rule in clients] } headers = { 'Authorization' : f'Bearer {token}' } if existing_rule_id is None: url = f"http://{BASE_URL}:{BASE_PORT}/api/nginx/access-lists" response = requests.post(url, json=payload, headers=headers)
time.sleep(60)
After executing the script
Adding access list adding to ruleid : 11 Error adding access list. (413) (Code 413 Request Entity Too Large)
Expected behavior
That the records are inserted correctly.
Screenshots
Operating System
The script is being executed Ubuntu 22.04.4 LTS
Additional context