Manually enable https redirect per router

Hello,

I want to be able to set https redirects manually per router.

To achieve i tried the following.

I setup a simple Scheme Redirect in a file provider:

http:
  middlewares:
    https-redirect:
      redirectScheme:
        scheme: https
        permanent: true

and then for containers that should be redirected i set it up with 2 routers

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard-http.rule=Host(`traefik.SOMEURL.COM`)"
      - "traefik.http.routers.dashboard-http.entrypoints=web"
      - "traefik.http.routers.dashboard-http.middlewares=https-redirect@file"

      - "traefik.http.routers.dashboard.rule=Host(`traefik.SOMEURL.COM`)"
      - "traefik.http.routers.dashboard.entrypoints=websecure"
      - "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"

and for containers that should only have http i just setup one router

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.test-http.rule=Host(`test.SOMEURL.COM`)"
      - "traefik.http.routers.test-http.entrypoints=web"

From my unterstanding this should mean i can reach http://test.SOMEURL.COM

yet for some reason it still redirects to https with a 307 Temporary Redirect

The dashboard shows that the test-http routes does not have the redirect middleware applied.

the entrypoints defined in the config look like this:

entryPoints:
  web:
    address: :80
  websecure:
    address: :443
    http:
      tls: true

So what am i overlooking here?

on a sidenote. shoudn’t the “permanent: true” flag in the middleware mean that redirects are permanent, as in 308 or something? Even on the containers with the middleware they redirect with 307.

Maybe enable Traefik debug log (doc) and Traefik access log in JSON format (doc) for further insights.

JSON access log will tell you if the target service or Traefik itself was responding with the redirect.

Well, yeah. Thanks for reminding me i was just being dumb, apparently.

Apparently in the compose.yaml for traefik i had changed the name of the network at some point but it looks like i forgot to change the name in providers.docker.network where it defines the default networks for all docker providers. And the log did indeed show a warning so it seems to have gotten confused i guess.