NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.9k stars 2.66k forks source link

automate proxy hosts and certs via env vars?? #740

Closed PLCMercenary closed 3 years ago

PLCMercenary commented 3 years ago

Checklist

What is troubling you?

Docker compose env vars for all proxy hosts VIRTUAL_HOST = domain.example.com VIRTUAL_PORT = 1880 LETSENCRYPT_HOST = domain.example.com LETSENCRYPT_EMAIL = me@domain.com

why do I still have to manually enter an IP and a PORT when they change all the time???? What is the method to automate or what am I missing for an API that I can use environment vars to handle for each session?

This project is really great and the front end is awesome.. Id love to not have to spend as much time looking at it.

Clear and Concise Description : I would like to use environment vars in docker run or docker compose to automate the nginx-proxy, and the nginx-proxy-le, rather than using the GUI to enter the information such as the IP addresses or the external ports that change every time I restart a container.

jc21 commented 3 years ago

This project, being able to create multiple hosts and have multiple users, doesn't lend itself well to a env-var-only configuration.

Since the UI is just a pretty API client, you can use the API to update any host yourself too. I don't have any documentation for it though, but if you inspect the browser's network traffic when using the UI you'll be able to see the API requests to use.

My last thought though - why are your ip addresses / (external?) ports changing? Wouldn't your other services be binding to defined ports?

PLCMercenary commented 3 years ago

I have a bunch if industrial automation, SCADA, and PLC runtimes and data gateways that all want to use the same ports, hostnames and serial data addresses, I quit trying to manage them, and just let docker do that, and use domains for everything.

I guess NPM would normally be pointing at the application port and not the exposed port so not changing often.. I have been testing with NPM running on a clustered lxc.. and thats had me playing with ports, however the IP's are constantly shifting for sure, I havent been able to get a network alias or hostname to work in place of an IP.. but I guess that could be a solution??

Ah.. the access lists.. certainly does make the automation a bit more complex. I will dig a bit into the the API and see what I can cook up.

quick question.. You dont have any examples of, or have time to poke at proxying MQTT data using streams? there is some way to loadbalance with Nginx.. and there are public brokers at test.mosquitto.org, and broker.hive.com so there is some way to get the traffic directed using a domain name. but I dont have enough experience with the web stuff to make sense of how that should work for non HTTP traffic.

Thanks for the quick response!! again awesome project.

jc21 commented 3 years ago

The streams support is pretty basic, it's just a port forward and doesn't handle load balancing or SNI for hostnames etc (requested by others). I don't plan to put any attention into this area anytime soon either.

If your docker/lxc services are running on the same host, could you use a virtual network with internal name resolution for those services?

PLCMercenary commented 3 years ago

Thats what I am looking at now.. I cant get the docker assigned network aliases or the container "hostnames" to actually proxy with NPM.. the only way it actually resolves is the IP address.. Maybe that is a function of the certificate?? I am going to figure out some internal dns stuff that will work.

What?? streams is not on the top of your list this moment??! what sort of a business is this?? I demand a refund ! Not serious.. I appreciate your suggestions.. and Ill close this request. Thanks again for the super fast responses!

If you DO happen to come across a thread, or you get an issue resolved, or slack chat, read a medium post, whatever about someone who's got mqtt messages proxying.. a link or a snippet in the readme would be total blessing. If I get it worked out (which is seeming a battle Im not skilled properly to even comment on) I will write it up and pass a link your way.

CWempe commented 2 years ago

I cannot believe there aren't more people asking for this feature. 😲

I found this project, which adds this feature as a separate container.

Unfortunately it hasn't been updated in a long time. It looks like there some hard coded parameters you might need to change to your environment. And even ater that I could not get it to work. When I start nginx-proxy-manager-assistant my nginx-proxy-manager stops working and I need to restart the container.

Maybe someone has more luck or could even pick up that project and update it.

m-chingis commented 2 years ago

@CWempe , the logic inside npm-assistant is pretty simple, you can try to automate to fork it and adapt to your env. Or make a bash script. I have a very-very draft version of bash script for automatic proxy-host addition. In a week or two will implement it as part of Gitlab-ci\cd. Will post as snippets to my github repo.