Stupid question time about routing

Time for some stupid questions. I was playing around with https and ended up ditching it because I couldn't get the basics working. I haven't played around with web development in quite a few years and think I have forgotten more than I ever learned. The questions I'm about to ask may not even relate to Traefik, in which case please let me know and I'll go looking elsewhere (domain related). I suppose that's the big question, which of these issues are handled by Traefik and which ones are handled by something else.


  • Domain names are with NameCheap and DNS point to DigitalOcean (, etc).
  • DNS records handled through DigitalOcean:
    • A record points to server IP
    • CNAME * is an alias of

What works:

  • going to works and shows appropriate content such as traefik dashboard, flask site, etc.

What doesn't work:

  • Putting www in front, such as shows "404 page not found" but works for traefik dashboard so I'm wondering if this get's handled in flask or in Traefik? I tried searching and came up empty handed, maybe I just searched the wrong thing.
  • How do you do redirects in Traefik 2.0 to go from http to https automatically so your really only running one website, can you do that? I spent ages trying to do this when I was first trying to learn Traefik and gave up.

Thanks in advance for any assistance.

1 Like

Hi, have you found any solution to this problem?

Hello @mindgonemad,

This is because Traefik treats subdomains as separate hosts, as it should. The Traefik dashboard is specifically written to not require a host, and therefore works as it should.

As for redirects, you should look at the RedirectScheme Middleware:

An example of this in the docker provider can be found here:

Thanks for responding Daniel.

Another question regarding redirects; I stumbled on an Containous article that uses a global https redirect ( but could never get it working. Is this the way we should be heading or should we be putting a redirect on every service as per the example that was posted?

I should clarify: It redirects to https but shows 404 on both services, maybe the TLS isn't working properly???

version: "3.7"


    image: "traefik:v2.0.2"
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker=true
      - --api=true
      #- --certificatesresolvers.leresolver.acme.caserver=
      - --certificatesresolvers.leresolver.acme.tlschallenge=true
      # Logging
      - "--log.level=ERROR" # DEBUG, ERROR, INFO???
      - "--log.filePath=/traefik.log"
      - "--log.format=json"
      - "80:80"
      - "443:443"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./logs/traefik.log:/traefik.log"
      - "./letsencrypt:/letsencrypt"
      # Dashboard
      - "traefik.http.routers.traefik.rule=Host(``)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.tls.certresolver=leresolver"
      - "traefik.http.routers.traefik.entrypoints=websecure"
      - "traefik.http.routers.traefik.middlewares=authtraefik"
      - "traefik.http.middlewares.authtraefik.basicauth.users=<basic_auth_stuff>"
      # global redirect to https
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"

      # middleware redirect
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - traefik-public

    image: containous/whoami:v1.3.0
      - "``)"
      - ""
      - ""
      - ""
      - ""
      - "traefik.http.middlewares.auth.basicauth.users=<basic_auth_stuff>"

    driver: overlay
    name: traefik-public