From 167815ea473fe74209dbd77448281779fca53fb6 Mon Sep 17 00:00:00 2001 From: ABM Ruman Date: Wed, 5 Feb 2020 13:31:49 +0600 Subject: [PATCH] add docker-compose for traefik:2.1 --- docker-compose.yml | 40 ++++++++++++++++++++++++++++++++++++++++ env.example | 6 ++++++ 2 files changed, 46 insertions(+) create mode 100644 docker-compose.yml create mode 100644 env.example diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ba0712f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: "3.5" + +services: + traefik: + container_name: traefik + image: traefik:2.1 + command: + - --entryPoints.web.address=:80 + - --entryPoints.websecure.address=:443 + - --log.level=${LOG_LEVEL} + - --providers.docker + - --providers.docker.exposedbydefault=false + - --api + ports: + - "80:80" + - "443:443" + networks: + - web + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + labels: + traefik.enable: true + + # redirection HTTP to HTTPS + traefik.http.routers.http_catchall.rule: hostregexp(`{host:.+}`) + traefik.http.routers.http_catchall.entrypoints: web + traefik.http.routers.http_catchall.middlewares: redirect + + # dashboard + traefik.http.routers.traefik.rule: host(`${DASHBOARD_PREFIX}${HOST}`) + traefik.http.routers.traefik.entrypoints: websecure + traefik.http.routers.traefik.service: api@internal + traefik.http.routers.traefik.tls: true + + # middlewares + traefik.http.middlewares.redirect.redirectscheme.scheme: https + +networks: + web: + external: true diff --git a/env.example b/env.example new file mode 100644 index 0000000..5f3499f --- /dev/null +++ b/env.example @@ -0,0 +1,6 @@ +# Environment variables for docker-compose.yml + +LOG_LEVEL=DEBUG +HOST=localhost +# subdomain for dashboard. DONT forget the dot (.) at the end +DASHBOARD_PREFIX=monitor.