Score:0

Nginx reverse proxy requires internal port to work when redirecting traffic to Docker host machine

cn flag

I've been using a Linux host machine with several docker containers running with one of those as Nginx Proxy Manager (from now on: NPM), which is just Nginx with a friendly UI.

NPM exposes ports 80 and 443 and redirects traffic to each container as per the proxy rules specified, a regular old reverse proxy configuration. All containers are instructed to connect to a bridge Docker network so NPM can easily reach them.

All of that works. Now I have a new service that needs to be exposed using NPM as well, the difference is that the service does not run on a container but rather in the host machine, and it is reachable at port 3711.

By doing my research and ended up with this suggestion:

extra_hosts:
    - "host.docker.internal:host-gateway"

By adding that to the docker-compose file under the NPM service, you allow it to reach any port on the host machine, and in fact by doing a ping from within the NPM container to host.docker.internal I got an answer. The problem is that after setting up the proxy rule, like I always do:

enter image description here

If I try to reach the service from the internet by ci-server.domain.com, I got a 502. BUT if I do ci-server.domain.com:3711 I can reach it!

Why Do I need to add the internal port to the domain? All my other services running on containers respond to 80/443 and get redirected internally to their ports.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.