Replies: 1 comment 3 replies
-
@pankalog I'm not 100% sure I got what you want to do but if it is this:
Then no, nginx-proxy with its current feature set won't allow you to do this. What is possible is either this (assuming port 80 on left side):
Or this:
Or any mix of both. What confuses me is that you mention running your container using network_mode host (or is the proxy alone ?). If that's the case, your container are already directly reachable on their respective port on the host and you don't need nginx-proxy at all. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I am making a project that is attempting to use nginx-proxy to dynamically assign multiple containers a single hostname, which are themselves created dynamically. We would like to maintain the look-and-feel of a "single computer system", meaning that we would like to allow multiple docker containers to appear as a single computational system, by allowing a single hostname to resolve different containers on different ports.
For example, I would like to use a single hostname (
userId.containers.example.com
) to access a container that could have an MQTT broker at port 8883, a container serving a database at port 5432, a frontend at port 80, etc.In my case, I have set up nginx-proxy using network_mode host, which means that the requests are reaching the container.
I took a look at
/etc/nginx/conf.d/default.conf
and I saw that the upstream for the hostname was setup properly, meaning that all 3 containers that had the same VIRTUAL_HOST were registered on that upstream, but here is the issue:This shows that only ports 80 and 443 are being listened to.
I would like to figure out a way to provide a 1-to-1 mapping of container ports to the VIRTUAL_HOST. so if the following ports are exposed:
container1:80
container2:5432
container2:3000
container3:8883
I would like them to be accessible from userId.containers.example.com:80,5432,3000,8883, etc. respectively.
Is there a way to do this using nginx-proxy or is this not really the correct use-case for this?
Thanks for your help, and thank you for maintaining!
Beta Was this translation helpful? Give feedback.
All reactions