| certs | ||
| custom | ||
| vhost.d | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.override.yml.sample | ||
| docker-compose.yml | ||
| generate-certs.sh | ||
| README.md | ||
| run.sh | ||
Nginx-proxy
Working on multiple docker applications on different ports can become confusing and annoying when there are conflicting ports.
jwilder/nginx-proxy allows access to multiple containers through different hostnames on the same HTTP(S) port.
This project provides a template to get you started using this tool, with:
- A wrapper script (
run.sh) - A docker-compose file (
docker-compose.yml) - A script to generate certificates (automatically called by
run.sh) - A custom virtualhost configuration sample
- An index page listing all currently proxied containers as a default virtual host
Nginx-proxy usage
- Configure
NGINX_PROXY_variables in.env
# Generate certificate for nginx-proxy (needs openssl on your host)
NGINX_PROXY_GEN_CERT=true
# nginx-proxy certificates path
NGINX_PROXY_CERT_PATH=./nginx-proxy/certs
# nginx-proxy certificate name (vhosts TLD)
NGINX_PROXY_CERT_NAME=docker
- Configure your container hostnames through the
VIRTUAL_HOSTenvironment variable:
docker run -e VIRTUAL_HOST=my-project.docker ...
or with docker-compose:
services:
my-project:
environment:
- VIRTUAL_HOST=my-project.docker
- Map these hostnames in your
hostsfile (/etc/hostsor%WinDir%\System32\drivers\etc\hosts)
127.0.0.1 my-project.docker
Note: with Docker Toolbox, you should use the Docker machine IP. You can find it with docker-machine ip
- Start the nginx-proxy container with the provided wrapper script:
./run.sh
You can then access your containers through the hostnames :
The proxy will be automatically reloaded when containers with configured hostnames are started or stopped.
SSL support
If you enable NGINX_PROXY_GEN_CERT, a SSL certificate will be generated in the NGINX_PROXY_CERT_PATH directory.
The name of the certificate (NGINX_PROXY_CERT_NAME) should be related to your virtualhost names
(the tld is enough, ie for myapp.docker, you can use docker)
https://github.com/jwilder/nginx-proxy#ssl-support
If there is a certificate corresponding to your hostname, the virtualhost will be configured to use HTTPS.
For more information, see https://github.com/jwilder/nginx-proxy
Index page
An index page listing all currently proxied containers is also provided as a default virtual host: