Redirect to https not working


I try to setup traefik with acme and a force redirect to https but it's not working. Here is my config:

    image: traefik:v2.0
      - "--log.level=INFO"
      # - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.http.acme.httpchallenge=true"
      - "--certificatesresolvers.http.acme.httpchallenge.entrypoint=web"
      - "<email>"
      - ""
      - "80:80"
      - "443:443"
      - "8080:8080"
      - web
      - acme:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

    image: nginx:alpine
      - web
    labels: web
      traefik.enable: true

      traefik.http.routers.<name>.tls.certresolver: http
      traefik.http.routers.<name>.rule: Host(`<name>.com`,`www.<name>.com`)
      traefik.http.routers.<name>.entrypoints: web

      traefik.http.middlewares.https-redirect.redirectscheme.scheme: https
      traefik.http.routers.<name>.middlewares: https-redirect@docker
      traefik.http.routers.<name>-secured.rule: Host(`<name>.com`,`www.<name>.com`)
      traefik.http.routers.<name>-secured.entrypoints: websecure
      traefik.http.routers.<name>-secured.tls: true

If I open the domain with http, I get a 404 error. If I change the schema to https, the page is displayed.

Hi @marvincaspar, is the string <name> in your snippet is redacted, or is it literally the string used?

Also, can you provide a full reproduction case? It is partial so the issue can come from different areas :slight_smile:

At first sight, I see a misconfiguration:

The label traefik.http.routers.<name>.tls.certresolver: http means that TLS is enabled on the router <name>. So there is no router able to match the request in plain HTTP.

You might want to change it to traefik.http.routers.<name>-secured.tls.certresolver: http and it should do the trick