Skip to content

Latest commit

 

History

History
62 lines (50 loc) · 1.66 KB

Readme.md

File metadata and controls

62 lines (50 loc) · 1.66 KB

Nginx reverse proxy

Simple docker + nginx configuration to make reverse proxy with HTTPS support

How to use

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).


Example of docker-compose file for service

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

List of environment parameters:

  • 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


Source

Repository was based on this article by François Romain.