32 lines
1.5 KiB
Markdown
32 lines
1.5 KiB
Markdown
nginx-proxy sets up a container running nginx and [docker-gen][1]. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
|
|
|
|
See [Automated Nginx Reverse Proxy for Docker][2] for why you might want to use this.
|
|
|
|
### Usage
|
|
|
|
To run it:
|
|
|
|
$ docker run -d -p 80:80 -p 443:443 -v /var/run/docker.sock:/tmp/docker.sock -t jwilder/nginx-proxy
|
|
|
|
Then start any containers you want proxied with an env var VIRTUAL_HOST=subdomain.youdomain.com
|
|
|
|
$ docker run -e VIRTUAL_HOST=foo.bar.com -t ...
|
|
|
|
Provided your DNS is setup to forward foo.bar.com to the a host running nginx-proxy, the request will be routed to a container with the VIRTUAL_HOST env var set.
|
|
|
|
### Multiple Ports
|
|
|
|
If your container exposes multiple ports, nginx-proxy will default to the service running on port 80. If you need to specify a different port, you can set a VIRTUAL_PORT env var to select a different one. If your container only exposes one port and it has a VIRTUAL_HOST env var set, that port will be selected.
|
|
|
|
### SSL Support
|
|
|
|
You can enable SSL by setting VIRTUAL_SSL_HOST on your container:
|
|
|
|
$ docker run -e VIRTUAL_HOST=foo.bar.com -e VIRTUAL_SSL_HOST=foo.bar.com -t ...
|
|
|
|
VIRTUAL_SSL_PORT can also be set on your container to override the default port, 443.
|
|
|
|
Self signed certs are generated on docker build, please replace them with your own for production use.
|
|
|
|
[1]: https://github.com/jwilder/docker-gen
|
|
[2]: http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/
|