Hi everyone, my compose-docker.yml configuration is
version: '3.6'
services:
traefik:
image: traefik:latest
restart: always
container_name: traefik
ports:
- "80:80" # <== http
#- "8080:8080" # <== :8080 is where the dashboard runs on
- "443:443" # <== https
command:
- --accessLog=true
- --accesslog.filepath=/var/log/traefik/access.log
- --accesslog.filters.statuscodes=301-302,400-499
- --api.insecure=false # <== Enabling insecure api, NOT RECOMMENDED FOR PRODUCTION
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc.
- --api.debug=true # <== Enabling additional endpoints for debugging and profiling
- --entrypoints.web.address=:80 # <== activa ACME
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443 # <== activa ACME
- --entrypoints.websecure.http.tls.domains[0].main=domain.com
- --entrypoints.websecure.http.tls.domains[0].sans=*.domain.com
- --certificatesresolvers.cloudflare.acme.email=admin@domain.com # <== activa ACME
- --certificatesresolvers.cloudflare.acme.dnschallenge=true
- --certificatesresolvers.cloudflare.acme.dnschallenge.delaybeforecheck=0
- --certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare
- --certificatesresolvers.cloudflare.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53
- --certificatesresolvers.cloudflare.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory
- --certificatesresolvers.cloudflare.acme.storage=/acme.json # <== activa ACME
- --log=true
- --log.level=DEBUG # <== Setting the level of the logs from traefik
- --providers.docker=true # <== Enabling docker as the provider for traefik
- --providers.docker.exposedbydefault=false # <== Don't expose every container to traefik
- --providers.file.filename=/dynamic.yaml # <== Referring to a dynamic configuration file
# - --providers.docker.network=host # <== Operate on the docker network named web
environment:
- "CF_API_EMAIL=email"
- "CF_API_KEY=API_KEY"
volumes:
- /var/run/docker.sock:/var/run/docker.sock # <== Volume for docker admin
- /home/odoo/Docker/security/traefik/acme.json:/acme.json
- /home/odoo/Docker/security/traefik/dynamic.yaml:/dynamic.yaml # <== Volume for dynamic conf file, **ref: line 27
networks:
- default
- traefik-public
labels:
- "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to$
- "traefik.docker.network=traefik-public"
- "traefik.http.routers.dashboard.entrypoints=websecure"
#- "traefik.http.routers.api.rule=Host(`subdomain.domain.com`)"
#- "traefik.http.routers.api.service=api@internal" # <== Enabling the api to be a service to acce$
- "traefik.http.routers.dashboard.rule=Host(`subdomain.domain.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
- "traefik.http.routers.dashboard.service=api@internal"
networks:
traefik-public:
external: true
default:
driver: bridge
1,1 At the beginning with a basic configuration I could go to the localhost:8080 and see the dashboard, now after configuring the DNS_Challenge and get the https working on my domain I cant see the dashboard but the domain is working is getting http to https through Cloudflare.
In the dynamic.yaml file I have this:
## Setting up the middleware for redirect to https ##
http:
middlewares:
redirect:
redirectScheme:
scheme: https