nginx作为docker上游代理与地图

尝试使用docker在代理之后使用nginx maps选项设置一堆应用程序,以便于使用大量的后端应用程序进行configuration。

我遇到的麻烦是容器不能解决我给了它的链接地址。

我试过使用dnsmasq,但那很麻烦,并没有给我一个工作的决议。

有什么build议么? 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/; } } } 

泊坞窗,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 

错误我不断得到:

 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"