mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-04-25 17:35:52 +03:00
[GH-ISSUE #703] If dockers containers are in the same host, couldn't be possible to use the container name and internal port? #593
Labels
No labels
awaiting feedback
bug
cannot reproduce
dns provider request
duplicate
enhancement
enhancement
enhancement
good first issue
help wanted
invalid
need more info
no certbot plugin available
product-support
pull-request
question
stale
troll
upstream issue
v2
v2
v2
v3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-proxy-manager-NginxProxyManager#593
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @joancifo on GitHub (Nov 7, 2020).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/703
Checklist
What is troubling you?
If dockers containers are in the same host, couldn't be possible to use the container name and internal port?
For now, we have to EXPOSE the port and assign the IP in proxy host. But theoretically shouldn't be enough using the container name and "the internal port" without having to expose it ?
For example, if a container of the same host exposes the port 3333, the web can be accessible by the port 3333 and also by the proxy.
Thanks!
@the-holger commented on GitHub (Nov 7, 2020):
If I understood you correctly then this is exactly what I am doing with (most of) my containers.
My setup is like this:
You can only use the name resolution (i.e. using the container name) when both Nginx Proxy Manager and the proxied Container are in a network together (not both bridged). The Docker documentation helped me a lot here.
@joancifo commented on GitHub (Nov 9, 2020):
Thanks for your reply.
Interesting, I didn't manage to connect via container name even they are in the same network (I use Portainer and both containers, NPM and a test container with a nginx, are in the bridge network).
Here I need to put the internal IP and the exposed port to connect to the containers (this works):

The container's name is "prova":

And the container configuration in Portainer:

However, using "prova" in NPM I get 502 Bad Gateway when I go to the URL.
@spcqike commented on GitHub (Dec 15, 2020):
are your container within the same docker-network?
each container can access all container that are in the same network. so if you have NPM with 172.17.0.1 and php with 172.17.0.2, nginx can access php via "php:80"
if you have isolated containers in stand alone networks (or stacks) with different IP ranges (npm as 172.17.0.1 and php as 172.18.0.1, ...) you must use the container IP (or, if you passtrough the container Ports to the host, you could also use the host ip and the port, like 192.168.0.32:8080)
i use several containers within one network and call them by name. so i need no "open" ports, except 80 and 443 (and 81). mysql, php, phpmyadmin, portainer, .... everything connects "local" in one docker network via container name. so in case of an container update/rebuild and therefore changed IP addresses, everything still works fine.