Nginx Proxy
| Nginx Proxy setup is not needed for local testing. Instructions from [Basic setup for local demo] are enough to get local demo up & running. |
Nginx Proxy (docker image jwilder/nginx-proxy) is auto-configurable reverse-proxy that routes traffic from your public IP to containers on the host
LetsEncrypt Nginx Proxy Companion (docker image jrcs/letsencrypt-nginx-proxy-companion) handles the automated creation, renewal and use of Let’s Encrypt certificates for proxyed Docker containers.
| In the following instructions, we assume you don’t have anything similar set up on your current environment. If you have other means to provide traffic forwarding and/or SSL certificate handling, proceed with caution! |
Please see Nginx Proxy and LetsEncrypt Nginx Proxy Companion Github pages to
-
Both images mount /var/run/docker.sock (read-only) and listen to docker events (when containers start or stop)
-
Containers (like Corteza server, and fronted application) that are exposed publicly no longer have to publish their ports on public IP
-
No complicated firewall or network forwarding rules are needed
-
Containers MUST (also) be on the same network as
nginx-proxy(in the examples we’re using network namedproxy) -
Nginx Proxy detects
VIRTUAL_HOSTon each container that comes online. Then it auto-generates configuration, reloads itself and starts forwarding HTTP traffic to that container -
LetsEncrypt companion detects
LETSENCRYPT_HOSTand starts certificate creation process with LE. It also reconfigures nginx-proxy, adds certificates and enables redirection from HTTP to HTTPS
docker-compose.yamlversion: '3.5'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
restart: always
networks:
- proxy
ports:
- "80:80"
- "443:443"
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
volumes:
- ./certs:/etc/nginx/certs
- ./htpasswd:/etc/nginx/htpasswd
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- ./custom.conf:/etc/nginx/conf.d/custom.conf:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
nginx-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginx-letsencrypt
restart: always
depends_on:
- nginx-proxy
volumes:
- ./certs:/etc/nginx/certs
- ./vhost.d:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
# Create network if it does not exist
networks: { proxy: { name: proxy } }
custom.conf Nginx configuration file next to docker-compose.yaml# Make sure we can upload at least 200Mb files
client_max_body_size 200M;
# Add other custom configs.
#
docker-compose up -d
docker-compose ps should produce something like: Name Command State Ports
-----------------------------------------------------------------------------------------------------
nginx-letsencrypt /bin/bash /app/entrypoint. ... Up
nginx-proxy /app/docker-entrypoint.sh ... Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp