Can't get auto-redirect working on 2.2.1

I have Traefik 2.2.1 running on my home server, exposing a few docker containers. This works fine, but the last thing I need to fix is http to https redirect. I no matter what I do, I can't get it to work. I have the following setup:

I run traefik with this middleware configured:

http:
  middlewares:
    https_redirect:
      redirectScheme:
        scheme: https
        permanent: true

This works, because I see the middleware existing in the traefik GUI. Now the next part is to apply this middleware to my running docker containers. I run each container using this command:

 /usr/bin/docker run --name=myserice \
                      --expose 2368 \
                       -d \
                       -l "traefik.http.routers.myservice.rule=Host(\"www.myservice.nl\",\"myservice.nl\")" \
                       -l "traefik.http.routers.myservice.tls=true" \
                       -l "traefik.http.routers.myservice.tls.certresolver=letsEncrypt" \
                       -l "traefik.http.routers.myservice.entrypoints=https" \
                       -l "traefik.http.routers.myservice.middlewares=https_redirect@file" \
                       -l "traefik.enable=true" \
                       ghost:latest

This exposes the service on https://myservice.nl, but it doesn't add a redirect when I try to connect to http. So for some reason I need to "tell" traefik to apply the redirect middleware, because this mechanism currently doesn't work.

I got it working with:

entrypoints:
  http:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https

  https:
    address: ":443"

in my traefik.yaml file.

That's it! I don't think this solution is documented, right?

Not sure where I found it. It was really quite an endeavor for such an obvious task.

Yeah tell me about it; was struggling with this for a couple of days :slight_smile: