From 32f16fee744ea2e0160d8292be209626948d9735 Mon Sep 17 00:00:00 2001 From: Fabio Tielen // Code Agency Date: Wed, 10 Jan 2024 14:13:35 +0100 Subject: [PATCH] ADD: Traefik support - initial commit --- .env.example | 2 ++ docker-compose.override.local.yml | 6 ++++ docker-compose.override.production.yml | 6 ++++ docker-compose.yml | 43 ++++++++++++++++++++++++++ traefik/acme.json | 0 5 files changed, 57 insertions(+) create mode 100644 traefik/acme.json diff --git a/.env.example b/.env.example index d29a6d1..8e51b2a 100644 --- a/.env.example +++ b/.env.example @@ -144,6 +144,7 @@ ODOO_PROFILES="odoo" POSTGRES_PROFILES="postgres" NGINX_PROFILES="nginx" NGINX_PROXY_PROFILES="proxy" +TRAEFIK_PROFILES="traefik" ACME_COMPANION_PROFILES="acme" KEYDB_PROFILES="keydb" MINIO_PROFILES="minio" @@ -156,6 +157,7 @@ KEYDB_TAG=latest MINIO_TAG=latest NGINX_TAG=1.25.3 NGINX_PROXY_TAG=1.4.0 +TRAEFIK_TAG=2.11 ACME_COMPANION_TAG=2.2.9 PGADMIN_TAG=8.1 diff --git a/docker-compose.override.local.yml b/docker-compose.override.local.yml index 690dc5c..e5bfcf8 100644 --- a/docker-compose.override.local.yml +++ b/docker-compose.override.local.yml @@ -21,6 +21,12 @@ services: - 80:80 - 443:443 + traefik: + restart: 'no' + ports: + - 80:80 + - 443:443 + letsencrypt: restart: 'no' diff --git a/docker-compose.override.production.yml b/docker-compose.override.production.yml index 4aa221d..3054d5f 100644 --- a/docker-compose.override.production.yml +++ b/docker-compose.override.production.yml @@ -21,6 +21,12 @@ services: - 80:80 - 443:443 + traefik: + restart: 'unless-stopped' + ports: + - 80:80 + - 443:443 + letsencrypt: restart: unless-stopped diff --git a/docker-compose.yml b/docker-compose.yml index 7a34114..48687ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -117,6 +117,48 @@ services: - internal profiles: [$NGINX_PROXY_PROFILES] + traefik: + container_name: traefik + image: "traefik:${TRAEFIK_TAG}" + networks: + - internal + command: + - --api.dashboard=true + - --api.insecure=false + - --api.debug=true + - --entrypoints.web.address=:80 + - --entrypoints.websecure.address=:443 + - --providers.docker + - --log.level=INFO + - --accesslog.filepath=/var/log/traefik/access.log + - --certificatesresolvers.leresolver.acme.httpchallenge=true + - --certificatesresolvers.leresolver.acme.httpchallenge.entrypoint=web + - --certificatesresolvers.leresolver.acme.email=xxxxxx@yourdomain.tld #Set your email address here, is for the generation of SSL certificates with Let's Encrypt. + - --certificatesresolvers.leresolver.acme.storage=/acme.json + # - --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory + - --serversTransport.insecureSkipVerify=true + tty: true + volumes: + - "/var/run/docker.sock:/var/run/docker.sock:ro" + - "./acme.json:/acme.json" + - traefik_logs:/var/log/traefik + labels: + - "traefik.enable=true" + + # Catch all HTTP trafic and redirect it to HTTPS + - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)" + - "traefik.http.routers.http-catchall.entrypoints=web" + - "traefik.http.routers.http-catchall.middlewares=redirect-to-https" + - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + + # Traefik Dashboard route + - "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.yourdomain.tld`)" + - "traefik.http.routers.traefik-dashboard.entrypoints=websecure" + - "traefik.http.routers.traefik-dashboard.tls.certresolver=leresolver" + - "traefik.http.routers.traefik-dashboard.service=api@internal" + profiles: [$TRAEFIK_PROFILES] + + letsencrypt: image: nginxproxy/acme-companion:${ACME_COMPANION_TAG} depends_on: @@ -216,6 +258,7 @@ volumes: vhost: certs: acme: + traefik_logs: networks: internal: diff --git a/traefik/acme.json b/traefik/acme.json new file mode 100644 index 0000000..e69de29