Nginx as docker proxy with maps
Trying to use docker to set up a suite of applications behind a proxy using the nginx maps option to simplify configuration with a lot of backend applications.
The problem I am facing is this container will not resolve the addresses I gave it with links.
I tried using dnsmasq but it was troublesome and didn't give me a working permission.
Any suggestions? nginx.conf:
events {
worker_connections 1024;
}
http {
map $hostname $destination {
hostnames;
default host1:81;
host1.test.local host1:81;
host2.test.local host2:82;
host3.test.local host3:83;
}
server {
location / {
proxy_pass http://$destination/;
}
}
}
docker-compose.yml:
webproxy:
build: nginx:latest
ports:
- "80:80"
volumes:
- nginx.conf:/etc/nginx/nginx.conf
links:
- "host1:host1"
- "host2:host2"
- "host3:host3"
host1:
image: nginx:latest
ports:
- "81:80"
volumes:
- host1/index.html:/usr/share/nginx/html/index.html
host2:
image: nginx:latest
ports:
- "82:80"
volumes:
- host2/index.html:/usr/share/nginx/html/index.html
host3:
image: nginx:latest
ports:
- "83:80"
volumes:
- host3/index.html:/usr/share/nginx/html/index.html
The error I keep getting:
webproxy_1 | 2015/07/14 16:44:11 [error] 5#0: *1 no resolver defined to resolve host1, client: 10.0.2.2, server: , request: "GET / HTTP/1.1", host: "host2.test.local:8281"
webproxy_1 | 10.0.2.2 - - [14/Jul/2015:16:44:11 +0000] "GET / HTTP/1.1" 502 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0"
+3
source to share
No one has answered this question yet
Check out similar questions: