Middleware @file ignored in labels

Hi,
I am using traefik as a Docker container.
Now I want to define a middleware in my dynamic config to use for some containers only (Basic example: https-redirect). Unfortunately, traefik just seems to ignore my configuration by the labels.

Static config:

[...]
providers:
    file:
        filename: /etc/traefik/dynamic/dynamic.yaml
        watch: true
    docker:
        exposedByDefault: false
        network: web

entryPoints:
  web:
    address: ":80"
  web-tls:
    address: ":443"
[...]

Dynamic config:

http:
  middlewares:
    redirect-to-https:
        redirectScheme:
            scheme: https

docker-compose labels:

        - traefik.enable=true
        - traefik.http.routers.xyz.rule=Host(`a.domain.xyz`)
        - traefik.http.services.xyz.loadbalancer.server.port=80
        - traefik.http.routers.xyz.tls=true
        - traefik.http.routers.xyz.tls.certresolver=xyz
        - traefik.http.routers.xyz.middlewares=redirect-to-https@file

The configuration about the middleware is simply ignored, I get a 404 when I try to load the http-version.

Funnily, the config is not ignored completely. When I type an invalid name at the labels, it does log an error, that the middleware does not exist but it just completely ignores it when I type a correct one.

Thank you in advance for your help!

Christoph

If you always want a redirect from port 80 to 443, you can configure it directly in the entrypoint. Docs.

Hi,
Thanks for your answer. The problem is, that this is not the only middleware that I need and I only need it for some containers.