So, I'm trying to setup SSL through Letsencrypt and proxy it (or just use dns) via cloudflare. This is my current config:
services:
traefik:
image: traefik:2.9
restart: unless-stopped
networks:
- traefik
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /data/traefik/logs:/var/log
- /data/traefik/certs/:/var/certs/
command:
- --certificatesresolvers.le.acme.email=mail@example.com
- --certificatesresolvers.le.acme.storage=/var/certs/acme.json
# - --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory # Uncomment to enable testing server
- --certificatesresolvers.le.acme.dnschallenge=true
- --certificatesresolvers.le.acme.dnschallenge.provider=cloudflare
- --api.insecure=false
- --api.dashboard=true
- --log.level=INFO
- --log.filepath=/var/log/traefik.log
- --accesslog=true
- --accesslog.filepath=/var/log/access.log
- --accesslog.bufferingsize=100
- --accesslog.fields.defaultmode=keep
- --accesslog.fields.headers.defaultmode=keep
- --accesslog.fields.headers.names.Authorization=drop
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --providers.docker.network=traefik
- --entrypoints.http.address=:80
#- --entrypoints.http.http.redirections.entrypoint.to=https
#- --entrypoints.http.http.redirections.entrypoint.scheme=https
#- --entrypoints.http.forwardedheaders.insecure=true
- --entrypoints.https.address=:443
environment:
- CF_API_EMAIL=mail@example.com
- CF_DNS_API_TOKEN=SOME_TOKEN
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`traefik.example.com`)"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.middlewares=api-basic-auth@docker"
- "traefik.http.middlewares.api-basic-auth.basicauth.users=USERNAME:SOME_PASSWORD_HASH"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=le"
- "traefik.http.routers.traefik.tls.domains[0].main=example.com"
- "traefik.http.routers.traefik.tls.domains[0].sans=*.example.com"
networks:
traefik:
external: true
But https just spins forever (Postman gives 301), and http works fine. If I try to redirect http to https, redirects overflow... What am I doing wrong?