nginx - Assigning vhosts to Docker ports -


i have wildcard dns set web requests custom domain (*.foo) map ip address of docker host. if have multiple containers running apache (or nginx) instances, each container maps apache port (80) external inbound port.

what make request container-1.foo, mapped correct ip address (of docker host) via custom dns server, proxy default port 80 request correct docker external port such correct apache instance specified container able respond based on custom domain. likewise, container-2.foo proxy second container's apache, , on.

is there pre-built solution this, best bet run nginx proxy on docker host, or should write node.js proxy potential manage docker containers (start/stop/reuild via web), or...? options have make using docker containers more natural event , not extraneous ports , container juggling?

this answer might bit late, take @ jason wilder's nginx-proxy docker image. when running docker container of image, nginx server set reverse proxy other containers no config maintain.

just run other containers virtual_host environment variable , nginx-proxy discover ip:port , update nginx config you.

let dns set *.test.local maps ip address of docker host, start following containers quick demo running:

# start reverse proxy docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy  # start first container http://tutum.test.local docker run -d -e "virtual_host=tutum.test.local" tutum/hello-world  # start second container http://deis.test.local docker run -d -e "virtual_host=deis.test.local" deis/helloworld 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -