I a using nginx as a reversproxy for a golang app.
I run the 2 docker containers like this
docker run --rm -t -p 8080:8080 --name goapp helloworld-go
docker run --rm -p 8000:80 --link goapp:abc.xyz --name nginx-proxy foo/nginx
when I run
docker exec -it nginx-proxy cat /etc/hosts
output is below as you can see 172.17.0.2 is mapped to abc.xyz
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 abc.xyz d9000af82a8f goapp
172.17.0.3 ebf96988c18c
nginx default.conf
server {
listen 80;
location / {
try_files $uri @upstream;
}
location @upstream{
proxy_pass http://$proxy_pass;
}
}
nginx map
map $host $proxy_pass {
hostnames;
www.mydomain.com abc.xyz:8080;
}
but if I put proxy_pass http://abc.xyz:8080
it works. It is able to resolve based on what is in the /etc/hosts of the nginx container.
How to I force nginx to resolve to nginx container’s /etc/hosts. What IP should I put for the resolver directive to that it is force to look at nginx container’s /etc/hosts?