Archived
1
0
Fork 0
Bootstrap project for jwilder/nginx-proxy, an automated nginx proxy for Docker containers
This repository has been archived on 2025-05-18. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2018-06-25 11:18:32 +02:00
certs nginx-proxy conf 2017-11-24 19:14:58 +01:00
custom refactor / cleanup 2018-05-26 18:54:25 +02:00
vhost.d vhost.d - .gitignore 2018-05-28 12:57:58 +02:00
.env.example refactor / cleanup 2018-05-26 18:54:25 +02:00
.gitignore refactor / cleanup 2018-05-26 18:54:25 +02:00
docker-compose.override.yml.sample refactor / cleanup 2018-05-26 18:54:25 +02:00
docker-compose.yml restart policy 2018-06-25 11:18:32 +02:00
generate-certs.sh refactor / cleanup 2018-05-26 18:54:25 +02:00
README.md refactor / cleanup 2018-05-26 18:54:25 +02:00
run.sh Cert generation refactor 2018-05-26 17:41:09 +02:00

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_HOST environment 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 hosts file (/etc/hosts or %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:

Nginx proxy index