NginxProxyManager / nginx-proxy-manager

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

Using service names in docker swarm #3711

Open FlyingPersian opened 2 months ago

FlyingPersian commented 2 months ago

Hello,

I'm struggling to configure npm proxies using service names in docker swarm.

I've put NPM and my other services into the same overlay network. To test if it's working, i entered the container's console and pinged NPM successfully. Then, I created a proxy and used the same hostname I pinged earlier to setup the proxy. When I go to the URL, it gives me a 502 Bad gateway. When I used the IP instead of the hostname, it works.

What can I do to fix this? Is this even possible on docker swarm?

I found similar instructions on the NPM website: https://nginxproxymanager.com/advanced-config/

Somebody else described the process for docker swarm on reddit: https://www.reddit.com/r/selfhosted/s/GlNMq5YuI4

gratiachristi95 commented 2 months ago

Use container service name and then put .localhost after it. I would suggest against doing it this way for security purposes. You should put it on a separate docker network so that your containers are isolated by networking. Here is the link That explains some best practices:

https://medium.com/container-chronicles/the-fundamentals-of-container-networking-best-practices-and-key-considerations-ebc3c8bf2691