diff --git a/README.md b/README.md index 7d3e26d..ef9150f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ To run it: $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy -Then start any containers you want proxied with an env var VIRTUAL_HOST=subdomain.youdomain.com +Then start any containers you want proxied with an env var `IRTUAL_HOST=subdomain.youdomain.com` $ docker run -e VIRTUAL_HOST=foo.bar.com ... @@ -24,3 +24,30 @@ If your container exposes multiple ports, nginx-proxy will default to the servic ### Multiple Hosts If you need to support multipe virtual hosts for a container, you can separate each enty with commas. For example, `foo.bar.com,baz.bar.com,bar.com` and each host will be setup the same. + +### Separate Containers + +nginx-proxy can also be run as two separate containers using the [jwilder/docker-gen](https://index.docker.io/u/jwilder/docker-gen/) +image and the official [nginx](https://registry.hub.docker.com/_/nginx/) image. + +You may want to do this to prevent having the docker socket bound to a publicly exposed container service. + +To run nginx proxy as a separate container you'll need to have [nginx.tmpl](https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl) on your host system. + +First start nginx with a volume: + + + $ docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx + +Then start the docker-gen container with the shared volume and template: + +``` +$ docker run --volumes-from nginx \ + -v /var/run/docker.sock:/tmp/docker.sock \ + -v $(pwd)/templates:/etc/docker-gen/templates + -t docker-gen -notify-sighup nginx -watch --only-published /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf +``` + +Finally, start your containers with `VIRTUAL_HOST` environment variables. + + $ docker run -e VIRTUAL_HOST=foo.bar.com ...