1

According to this website, when a network of containers is set up, each container listens to port 80 by default and this can lead to conflict between incoming traffic. This is solved by using the Nginx reverse proxy (also listening on port 80) which looks for the VIRTUAL_HOST variable and routes the traffic to the right container.

But here's what I don't understand. If Nginx is also listening on port 80 (like all the other containers), then how does that solve the traffic conflict problem? Since Nginx is listening on port 80, then shouldn't the conflict problem still persist? Does Nginx automatically capture all incoming traffic regardless of the port number of the other containers? I find this whole concept quite confusing.

1 Answer 1

0

If Nginx is also listening on port 80 (like all the other containers), then how does that solve the traffic conflict problem?

Perhaps I am misreading the article, but it seems likely that "all the other containers" aren't listening on port 80 (emphasis added):

By default, Docker services all listen on port 80, which would create conflicts for incoming traffic. You can change the listening port, of course, but no one wants to type in coolwebsite.com:34567 to access their favorite site.

What if, instead, you could use nginx to route traffic arriving at coolwebsite.com to a unique to a container listening on the 34567 port, and route traffic arriving at anothercoolwebsite.net to a second container listening to 45678?

In this scenario, Nginx seems to be the only web server listening on port 80.

Does Nginx automatically capture all incoming traffic regardless of the port number of the other containers?

Nginx would capture all the traffic on port 80. That is, http://coolwebsite.com is effectively equivalent to http://coolwebsite.com:80 under most software. Nginx would then be relaying traffic between port 80 and whatever port the Docker container(s) were running on, dependant on hostname.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .