Redirect to https not working

Hi,

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

  traefik:
    image: traefik:v2.0
    command:
      - "--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"
      - "--certificatesresolvers.http.acme.email=<email>"
      - "--certificatesresolvers.http.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    networks:
      - web
    volumes:
      - acme:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  nginx:
    image: nginx:alpine
    networks:
      - web
    labels:
      traefik.docker.network: 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