1

How do we get NGINX reverse proxy to proxy_pass into the right IP/resolve the container's hostname? I get the notion that resolver pointing to an exposed Docker-embedded DNS is ideal.

Context: Debian Host (not dockerized) NGINX. Docker containers are on same host and necessarily on an overlay network and working well in their own right.

I've been experimenting & reading for hours on this and similar posts include:

https://stackoverflow.com/questions/35744650/docker-network-nginx-resolver

https://stackoverflow.com/questions/39729663/query-docker-embedded-dns-from-host

I was unable to get nslookup to work with Consul and various DNSmasq stuff

socat approach nearly got me there, but it resolves and spits out the non-exposed (non-overlay) network IP

2
  • 1
    Have a look at jwilder automatic nginx proxy for docker. There now other products offering the same kind of service (and much more... like traefik), but jwilder implementation is simple and easy to study to understand how things are done. Commented Jan 4, 2020 at 11:41
  • Quite interesting -- especially the docker-gen part!
    – Malachi
    Commented Jan 6, 2020 at 8:14

1 Answer 1

1

What are you trying to achieve? As far as I know, when running a docker container you should open its ports on the docker host. This way the nginx proxy configuration can point to the desired port on the local address (localhost/127.0.0.1).

For example I would run: docker run -p 8080:8080 myapp

Then configure Nginx with:

location / {
    proxy_pass http://127.0.0.1:8080;
    ... other desired options ...
}
1
  • My use case originally was containers were floating on a network, possibly DHCP'd, with nginx proxy elsewhere
    – Malachi
    Commented Jan 6, 2020 at 8:13

You must log in to answer this question.

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