Simple docker + nginx configuration to make reverse proxy with HTTPS support
1. Place docker-compose.yml
and nginx.tmpl
in one folder.
2. Create external network nginx-proxy
$ docker network create nginx-proxy
3. And start service with
$ docker-compose up -d
4. Then start service container(s).
IMPORTANT: Proxy containers and service containers must be in common external network (nginx-proxy in example).
version: '3'
services:
flask:
container_name: flask
restart: always
build:
context: .
dockerfile: Dockerfile-flask
networks:
- nginx-proxy
environment:
- VIRTUAL_HOST=domain.com,www.domain.com
- LETSENCRYPT_HOST=domain.com
- [email protected]
- VIRTUAL_PORT=5000
volumes:
- "./:/app"
entrypoint: /flask-entrypoint.sh
expose:
- 5000
networks:
default:
external:
name: nginx-proxy
-
VIRTUAL_HOST=domain.com,www.domain.com
- your domain (add www alias if you need to) -
VIRTUAL_PORT=5000
- port of your service (must be exposed) -
LETSENCRYPT_HOST=domain.com
- host to generate LetsEncrypt sertificate (matches your domain) -
[email protected]
- email to generate LetsEncrypt sertificate
Repository was based on this article by François Romain.