Cannot get https to work through cloudflare?

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... :frowning: What am I doing wrong?

1 Like

Turns out it was just me being stupid, and I had accidentally pressed an additional number to my port forwarding... It now works, but I get a 404 not found on the https server?

Hi @Supergamer1337 and thanks for your interest in Traefik,

Did you solve your issue?

It now works, but I get a 404 not found on the https server?

Are you getting a 404 when accessing the dashboard or another configured service?
Could you provide the debug logs and the complete configurations (if another container/service) is involved?

I managed to solve it! I had just incorrectly setup the router for https so it didn't route the traffic at all

1 Like