nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

NPM CLI/API?

Open doofusdavid opened this issue 4 years ago • 10 comments

I'm moving from a self-hosted nginx/let's encrypt server housing about 100 redirects to using NPM. I chose NPM because it's easier for my coworkers to create their own redirects without going through me. (why so many redirects? We're a university with always changing domains, sites, URLs, etc, and we've been asked to enable SSL on all of them.)

Is your feature request related to a problem? Please describe. Describe the solution you'd like I'm comfortable with the command line, and it's easy enough for me to get all existing ones as a list, but entering all of them into the GUI feels overwhelming for that many. I'd love a CLI, through docker, so that I could do something like, "nodepm create redirect --url=xxx --ssl=true --redirect_location=xxx"

Even creating the nginx/lets encrypt manually and getting those values into the database would be great.

Describe alternatives you've considered Hand entering through GUI

doofusdavid avatar Apr 04 '22 18:04 doofusdavid

I would also like to see this feature added. I work in a dev shop and we're (finally) looking to dockerize our staging environment. Our current process to provision a new site on our server is a custom script that handles all the cert and nginx configs (as well as setting up the db and directory structure, but that's not something that y'all need to worry about :P ) for us. We've considered just using that (or a slight alteration) anyway, but we really like the idea of having the dashboard for management once things are set up. If there was a CLI component to NPM, it would be a no-brainer to add it to our server.

embold-given avatar Jun 04 '22 21:06 embold-given

Adding my +1 here - I have a constantly-refreshing list of self-hosted services I'd like to test. Even within my home environment, I don't run them without an SSL cert, so there's a lot of work with adding/removing hosts through the GUI. All my options are the same (Base domain name, check box options, etc), so really the only thing I need to change is host IP (maybe), port and the sub-domain name.

I'm working on some automation using Selenium now, but it's not the best - there's lots of messy XPATH's to navigate since not all elements have names or ID's. Honestly, just having the option to select "default" base options for each entry, and only entering the options that need changing, would be a huge boon. If this isn't possible, then some type of CLI or API would be really appreciated!

I'd love to contribute if I can, though programming is not my profession so my knowledge is limited, but always willing to grow :)

kmanwar89 avatar Jul 23 '22 01:07 kmanwar89

+1 here. Currently I am managing alot of the nginx config using Ansible. It would be nice if there is a cli / api so I can replace nginx with npm. Thus I keep everything automated through Ansible while having the ability to modify and see an overview with the gui.

laurnts avatar Aug 02 '22 20:08 laurnts

I've spent some time working on documenting the API, and have had some success, but the API itself isn't....complete...

If you do a GET to <domain/IP where NPM is hosted>/api/schema, you'll get the API schema presented. I use editor.swagger.io to parse this into an easy to use format.

From there, the logic is:

  • Using basic auth, acquire a token
  • Use said token to authorize
  • Perform GET/PUT/POST/DELETE commands as necessary
  • De-authorize at the end

I'm working on a Python library now that'll interact with NPM via this API, but what I'm finding is portions of the internal API that the application uses (such as calls needed to add custom locations, or generally modify an entries' properties) don't seem to be documented anywhere, so I'm partially reverse-engineering it using the Developer Tools from my browser and watching the Network tab. I'm a network engineer, not a web developer, so this is a learning experience and, as such, might take a bit of time.

kmanwar89 avatar Sep 04 '22 22:09 kmanwar89

Hi, I started a project for Ansible. Maybe it will help. https://github.com/DenAV/nginx-proxy-manager-ansible

DenAV avatar Nov 28 '22 18:11 DenAV

@kmanwar89 were you able to release something? I'd love to see a cli option for when I want to add a host, but I'm not home. I tried added one directly to the database, but that didn't work.

godsgood33 avatar Aug 08 '23 16:08 godsgood33

@kmanwar89 were you able to release something? I'd love to see a cli option for when I want to add a host, but I'm not home. I tried added one directly to the database, but that didn't work.

Wow, I can't believe my last comment was almost a year ago!

No, I haven't really worked on it. Life has gotten in the way, and it seems when it rains, it pours :(

I won't realistically commit to something I can't deliver, and given that I'm not really a developer, just a networking nerd with a penchant for occasional deep-dives into topics out of my realm of expertise, I really don't know if anything I released would be considered complete/accurate.

Perhaps we can ask the developer to release more documentation around the API? I know there's lots of undocumented endpoints, and really without some additional guidance anything myself or others release would be a "best effort" type endeavour.

I do have the program I began writing a year ago - I'll have to find it, and when I do I will link the repo here.

kmanwar89 avatar Aug 18 '23 13:08 kmanwar89

@kmanwar89 were you able to release something? I'd love to see a cli option for when I want to add a host, but I'm not home. I tried added one directly to the database, but that didn't work.

Wow, I can't believe my last comment was almost a year ago!

No, I haven't really worked on it. Life has gotten in the way, and it seems when it rains, it pours :(

I won't realistically commit to something I can't deliver, and given that I'm not really a developer, just a networking nerd with a penchant for occasional deep-dives into topics out of my realm of expertise, I really don't know if anything I released would be considered complete/accurate.

Perhaps we can ask the developer to release more documentation around the API? I know there's lots of undocumented endpoints, and really without some additional guidance anything myself or others release would be a "best effort" type endeavour.

I do have the program I began writing a year ago - I'll have to find it, and when I do I will link the repo here.

Totally get it! Happens to me to. I'm a dev so maybe I can help out, so I'll take a look at the repo when you get it posted.

godsgood33 avatar Aug 18 '23 16:08 godsgood33

Issue is now considered stale. If you want to keep it open, please comment :+1:

github-actions[bot] avatar Feb 20 '24 01:02 github-actions[bot]