[Fixed]-Docker and Nginx proxy_pass between containers

1đź‘Ť

âś…

The localhost IP 127.0.0.1 inside your nginx only refers internally to the nginx container. There are a couple of solutions to this, either:

  1. The simple thing is to run your nginx container in “host-mode networking” mode. At this point, 127.0.0.1 actually refers to your container host and it should all be good. See the docs, but basically just adding --network="host" should work. The downside with this simplicity is that it’s slightly less secure.

  2. Alternatively, you can use “linked” containers, see the docs where you want the --link option. This way, from inside the nginx container you can use DNS resolution to access a different container, so you’d update your proxy_pass to the linked name. As a side note, doing this from docker-compose makes things considerably easier.

👤boyvinall

Leave a comment