Middleware@file not found, when using "custom" entrypoint

Apllying middleware from file is not working on "backend" entrypoint, but instead on the http, htpps entrypoint it's working as expected, without configuring something else there...

level=debug msg="Middleware name not found in config (ResponseModifier)" middlewareName=response-headers@file middlewareType=undefined entryPointName=backend routerName=somethingssl@docker

Output of traefik version : ( What version of Traefik are you using? )

(2.2)

What is your environment & configuration (arguments, toml, provider, platform, ...)?

[file] 
## dynamic configuration 
# dynamic_conf.toml 
[http.middlewares] 
  [http.middlewares.redirect.redirectScheme] 
    scheme = "https" 
# Security-Headers 
  [http.middlewares.security-headers.headers] 
    ForceSTSHeader = true 
    SSLRedirect = true 
    STSIncludeSubdomains = true 
    STSPreload = true 
    STSSeconds = 315360000  
  [http.middlewares.response-headers.headers.customResponseHeaders] 
    X-Powered-By = "developer" 
    Server = "developer"
version: '3.7'
services:
  traefik:
    image: traefik:v2.2
    command:
     - --log=true
     - --log.level=DEBUG
     - --accesslog=true
     - --accesslog.filepath=/var/log/traefik/access.log
     - --accesslog.filters.statuscodes=400-499
     - --providers.docker.exposedbydefault=false
     - --entryPoints.web.address=:80
     - --entryPoints.web-secure.address=:443
     - --entryPoints.backend.address=:50077
     - --global.sendAnonymousUsage=false
     - --global.checknewversion=false
     - --serverstransport.insecureskipverify=true
     - --providers.docker.swarmMode=true
     - --providers.docker.endpoint=unix:///var/run/docker.sock
     - --providers.docker.network=traefik_reverseproxy_net
     - --providers.file.filename=/etc/traefik/dynamic_conf.toml
     - --providers.file.watch=true
     - --certificatesResolvers.letsencrypt.acme.email=admin@someone.yolo
     - --certificatesResolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
     - --certificatesResolvers.letsencrypt.acme.tlsChallenge=true
     - --certificatesResolvers.letsencrypt.acme.keyType=RSA4096
    ports:
     - 80:80
     - 443:443
     - 50077:50077
    volumes:
     - traefik_reverseproxy_log:/var/log/traefik
     - /var/run/docker.sock:/var/run/docker.sock:ro
     - traefik_reverseproxy_letsencrypt:/letsencrypt
    networks:
     - net
    configs:
     -
      source: traefik_config
      target: /etc/traefik/dynamic_conf.toml
    logging:
      driver: json-file
    deploy:
      labels:
        swarmpit.service.deployment.autoredeploy: 'true'
      update_config:
        delay: 10s
        order: start-first
        failure_action: rollback
      restart_policy:
        delay: 10s
        max_attempts: 10
networks:
  net:
    driver: overlay
    driver_opts:
      opt: encrypted
volumes:
  traefik_reverseproxy_letsencrypt:
    external: true
  traefik_reverseproxy_log:
    external: true
configs:
  traefik_config:
    external: true

Could provide the docker-compose file with your services.

version: '3.7'
services:
  wordpress:
    image: wordpress:5.3.2
    networks:
     - traefik_reverseproxy_net
    deploy:
      labels:
        traefik.http.routers.wordpressssl.tls: 'true'
        traefik.http.routers.wordpressssl.tls.certresolver: letsencrypt
        traefik.http.routers.wordpressssl.rule: Host(`somehost.yolo`)
        traefik.http.services.wordpresslb.loadbalancer.server.scheme: http
        traefik.http.routers.wordpressssl.middlewares: security-headers@file, response-headers@file
        traefik.http.routers.wordpressssl.entrypoints: backend
        swarmpit.service.deployment.autoredeploy: 'true'
        traefik.http.services.wordpresslb.loadbalancer.passhostheader: 'true'
        traefik.http.services.wordpresslb.loadBalancer.server.port: '80'
        traefik.enable: 'true'

Middleware@file not found, when using “custom” entrypoint

You are not using a "custom" entry point in your docker-compose file.

The definitions of your middlewares used by wordpress are missing.

So could you provide a docker-compose related to your root problem.

edited...tre problem extends now to http and https entrypoints also. The definitions are in the dynamic_toml posted above.

Could provide the definition of sslproxy-headers.

Could you provide a reproducible case, because if you don't provide something that I can reproduce I cannot help you.

sorry left it accedentially there...is gone. secure@tls is also gone...this seems to work...

Sorry but there are again some missing elements.

So you try to create a real reproducible case in only one docker-compose file (traefik + wordpress) and all files that you use with the file provider.

Use the TLD .localhost to hide your domains.

version: '3.7'
services:
  traefik:
    image: traefik:v2.2
    command:
     - --log=true
     - --log.level=DEBUG
     - --accesslog=true
     - --accesslog.filepath=/var/log/traefik/access.log
     - --accesslog.filters.statuscodes=400-499
     - --providers.docker.exposedbydefault=false
     - --entryPoints.web.address=:80
     - --entryPoints.web-secure.address=:443
     - --entryPoints.backend.address=:50077
     - --global.sendAnonymousUsage=false
     - --global.checknewversion=false
     - --serverstransport.insecureskipverify=true
     - --providers.docker.swarmMode=true
     - --providers.docker.endpoint=unix:///var/run/docker.sock
     - --providers.docker.network=traefik_reverseproxy_net
     - --providers.file.filename=/etc/traefik/dynamic_conf.toml
     - --providers.file.watch=true
     - --certificatesResolvers.letsencrypt.acme.email=admin@someone.yolo
     - --certificatesResolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
     - --certificatesResolvers.letsencrypt.acme.tlsChallenge=true
     - --certificatesResolvers.letsencrypt.acme.keyType=RSA4096
    ports:
     - 80:80
     - 443:443
     - 50077:50077
    volumes:
     - traefik_reverseproxy_log:/var/log/traefik
     - /var/run/docker.sock:/var/run/docker.sock:ro
     - traefik_reverseproxy_letsencrypt:/letsencrypt
    networks:
     - net
    configs:
     -
      source: traefik_config
      target: /etc/traefik/dynamic_conf.toml
    logging:
      driver: json-file
    deploy:
      labels:
        swarmpit.service.deployment.autoredeploy: 'true'
      update_config:
        delay: 10s
        order: start-first
        failure_action: rollback
      restart_policy:
        delay: 10s
        max_attempts: 10

  wordpress:
    image: wordpress:5.3.2
    networks:
     - net
    deploy:
      labels:
        traefik.http.routers.wordpressssl.tls: 'true'
        traefik.http.routers.wordpressssl.tls.certresolver: letsencrypt
        traefik.http.routers.wordpressssl.rule: Host(`somehost.yolo`)
        traefik.http.services.wordpresslb.loadbalancer.server.scheme: http
        traefik.http.routers.wordpressssl.middlewares: security-headers@file, response-headers@file
        traefik.http.routers.wordpressssl.entrypoints: backend
        swarmpit.service.deployment.autoredeploy: 'true'
        traefik.http.services.wordpresslb.loadbalancer.passhostheader: 'true'
        traefik.http.services.wordpresslb.loadBalancer.server.port: '80'
        traefik.enable: 'true'
networks:
  net:
    driver: overlay
    driver_opts:
      opt: encrypted
volumes:
  traefik_reverseproxy_letsencrypt:
    external: true
  traefik_reverseproxy_log:
    external: true
configs:
  traefik_config:
    external: true

Have you try to run your example?

Could you provide logs?

I tried it again I hope it's working now

yes log:

level=debug msg="Middleware name not found in config (ResponseModifier)" entryPointName=backend routerName=wordpresshttp@docker middlewareName=response-headers@file middlewareType=undefined

Could you provide the full logs from the start of Traefik.

Your example cannot works: the files for the dynamic configuration are missing.

Could you provide a full reproducible example:

  • all files
  • an example that you have tried to run
  • the full logs
[file] 
## dynamic configuration 
# dynamic_conf.toml 
[http.middlewares] 
  [http.middlewares.redirect.redirectScheme] 
    scheme = "https" 
# Security-Headers 
  [http.middlewares.security-headers.headers] 
    ForceSTSHeader = true 
    SSLRedirect = true 
    STSIncludeSubdomains = true 
    STSPreload = true 
    STSSeconds = 315360000  
  [http.middlewares.response-headers.headers.customResponseHeaders] 
    X-Powered-By = "developer" 
    Server = "developer"

this is the dynamic conf toml...i don't know what you need here...

Could you provide the full logs from the start of Traefik.

I reduced your docker-compose file to try to reproduce easily:

  • no swarm
  • no let's encrypt
  • self-sign certs
  • no file provider

docker-compose.yml
version: "3.7"
services:
  traefik:
    image: traefik:v2.2
    ports:
      - "80:80"
      - "443:443"
      - "50077:50077"
    command:
     - --log.level=DEBUG
     - --api
     - --entryPoints.web.address=:80
     - --entryPoints.web-secure.address=:443
     - --entryPoints.backend.address=:50077
     - --providers.docker.exposedbydefault=false
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      traefik.enable: true

      traefik.http.routers.traefik.rule: Host(`traefik.localhost`)
      traefik.http.routers.traefik.entrypoints: web
      traefik.http.routers.traefik.service: api@internal

      traefik.http.middlewares.redirect.redirectScheme.scheme: https

      traefik.http.middlewares.security-headers.headers.ForceSTSHeader: true
      traefik.http.middlewares.security-headers.headers.SSLRedirect: true
      traefik.http.middlewares.security-headers.headers.STSIncludeSubdomains: true
      traefik.http.middlewares.security-headers.headers.STSPreload: true
      traefik.http.middlewares.security-headers.headers.STSSeconds: 315360000

      traefik.http.middlewares.response-headers.headers.customResponseHeaders.X-Powered-By: developer
      traefik.http.middlewares.response-headers.headers.customResponseHeaders.Server: developer

  wordpress:
    image: containous/whoami:v1.5.0
    labels:
      traefik.enable: true
      
      traefik.http.routers.wordpressssl.rule: Host(`wordpress.localhost`)
      traefik.http.routers.wordpressssl.entrypoints: backend
      traefik.http.routers.wordpressssl.tls: true
      traefik.http.routers.wordpressssl.middlewares: security-headers, response-headers
      
      # traefik.http.services.wordpresslb.loadBalancer.server.port: '80'
logs
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="Configuration loaded from flags."
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="Traefik version 2.2.0-rc2 built on 2020-03-11T17:42:16Z"
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"backend\":{\"address\":\":50077\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}},\"web\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}},\"web-secure\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/contributing/data-collection/\n"
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Start TCP Server" entryPointName=web-secure
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="Starting provider *traefik.Provider {}"
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Start TCP Server" entryPointName=backend
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Start TCP Server" entryPointName=web
traefik_1    | time="2020-03-17T23:09:38Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Configuration received from provider internal: {\"http\":{\"services\":{\"api\":{},\"dashboard\":{},\"noop\":{}}},\"tcp\":{},\"tls\":{}}" providerName=internal
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="No default certificate, generating one"
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Provider connection established with docker 19.03.7-ce (API 1.40)" providerName=docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"traefik\":{\"entryPoints\":[\"web\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.localhost`)\"},\"wordpressssl\":{\"entryPoints\":[\"backend\"],\"middlewares\":[\"security-headers\",\"response-headers\"],\"service\":\"wordpress-issue-traefik\",\"rule\":\"Host(`wordpress.localhost`)\",\"tls\":{}}},\"services\":{\"traefik-issue-traefik\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.3:80\"}],\"passHostHeader\":true}},\"wordpress-issue-traefik\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.23.0.2:80\"}],\"passHostHeader\":true}}},\"middlewares\":{\"redirect\":{\"redirectScheme\":{\"scheme\":\"https\"}},\"response-headers\":{\"headers\":{\"customResponseHeaders\":{\"Server\":\"developer\",\"X-Powered-By\":\"developer\"}}},\"security-headers\":{\"headers\":{\"sslRedirect\":true,\"stsSeconds\":315360000,\"stsIncludeSubdomains\":true,\"stsPreload\":true,\"forceSTSHeader\":true}}}},\"tcp\":{},\"udp\":{}}" providerName=docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareName=tracing middlewareType=TracingForwarder entryPointName=web routerName=traefik@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating middleware" middlewareType=Recovery entryPointName=web middlewareName=traefik-internal-recovery
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating Middleware (ResponseModifier)" entryPointName=backend routerName=wordpressssl@docker middlewareName=security-headers@docker middlewareType=Headers
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating Middleware (ResponseModifier)" routerName=wordpressssl@docker middlewareName=response-headers@docker middlewareType=Headers entryPointName=backend
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating middleware" serviceName=wordpress-issue-traefik middlewareName=pipelining middlewareType=Pipelining entryPointName=backend routerName=wordpressssl@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating load-balancer" serviceName=wordpress-issue-traefik entryPointName=backend routerName=wordpressssl@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating server 0 http://172.23.0.2:80" routerName=wordpressssl@docker serviceName=wordpress-issue-traefik serverName=0 entryPointName=backend
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Added outgoing tracing middleware wordpress-issue-traefik" entryPointName=backend routerName=wordpressssl@docker middlewareType=TracingForwarder middlewareName=tracing
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating middleware" entryPointName=backend routerName=wordpressssl@docker middlewareType=Headers middlewareName=response-headers@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Setting up customHeaders/Cors from %v{map[] map[Server:developer X-Powered-By:developer] false [] []  [] [] 0 false [] [] false false  map[] false 0 false false false false  false false      false}" middlewareName=response-headers@docker entryPointName=backend routerName=wordpressssl@docker middlewareType=Headers
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Adding tracing to middleware" routerName=wordpressssl@docker entryPointName=backend middlewareName=response-headers@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating middleware" middlewareName=security-headers@docker middlewareType=Headers entryPointName=backend routerName=wordpressssl@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Setting up secureHeaders from %v{map[] map[] false [] []  [] [] 0 false [] [] true false  map[] false 315360000 true true true false  false false      false}" entryPointName=backend routerName=wordpressssl@docker middlewareName=security-headers@docker middlewareType=Headers
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Adding tracing to middleware" middlewareName=security-headers@docker entryPointName=backend routerName=wordpressssl@docker
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="Creating middleware" entryPointName=backend middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik_1    | time="2020-03-17T23:09:38Z" level=debug msg="No default certificate, generating one"


traefik_1    | time="2020-03-17T23:10:34Z" level=debug msg="Serving default certificate for request: \"wordpress.localhost\""
traefik_1    | time="2020-03-17T23:10:34Z" level=debug msg="http: TLS handshake error from 172.23.0.1:45688: remote error: tls: bad certificate"
traefik_1    | time="2020-03-17T23:10:37Z" level=debug msg="Serving default certificate for request: \"wordpress.localhost\""
traefik_1    | time="2020-03-17T23:10:37Z" level=debug msg="vulcand/oxy/roundrobin/rr: begin ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9,fr-FR;q=0.7,fr;q=0.6,fr-FR;q=0.4,en-US;q=0.3,en;q=0.1\"],\"Dnt\":[\"1\"],\"Te\":[\"trailers\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0\"],\"X-Forwarded-Host\":[\"wordpress.localhost:50077\"],\"X-Forwarded-Port\":[\"50077\"],\"X-Forwarded-Proto\":[\"https\"],\"X-Forwarded-Server\":[\"319529818b48\"],\"X-Real-Ip\":[\"172.23.0.1\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"wordpress.localhost:50077\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:45698\",\"RequestURI\":\"/\",\"TLS\":null}"
traefik_1    | time="2020-03-17T23:10:37Z" level=debug msg="vulcand/oxy/roundrobin/rr: Forwarding this request to URL" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9,fr-FR;q=0.7,fr;q=0.6,fr-FR;q=0.4,en-US;q=0.3,en;q=0.1\"],\"Dnt\":[\"1\"],\"Te\":[\"trailers\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0\"],\"X-Forwarded-Host\":[\"wordpress.localhost:50077\"],\"X-Forwarded-Port\":[\"50077\"],\"X-Forwarded-Proto\":[\"https\"],\"X-Forwarded-Server\":[\"319529818b48\"],\"X-Real-Ip\":[\"172.23.0.1\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"wordpress.localhost:50077\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:45698\",\"RequestURI\":\"/\",\"TLS\":null}" ForwardURL="http://172.23.0.2:80"
traefik_1    | time="2020-03-17T23:10:37Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.9,fr-FR;q=0.7,fr;q=0.6,fr-FR;q=0.4,en-US;q=0.3,en;q=0.1\"],\"Dnt\":[\"1\"],\"Te\":[\"trailers\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0\"],\"X-Forwarded-Host\":[\"wordpress.localhost:50077\"],\"X-Forwarded-Port\":[\"50077\"],\"X-Forwarded-Proto\":[\"https\"],\"X-Forwarded-Server\":[\"319529818b48\"],\"X-Real-Ip\":[\"172.23.0.1\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"wordpress.localhost:50077\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"172.23.0.1:45698\",\"RequestURI\":\"/\",\"TLS\":null}"

I don't reproduce your issue.

I think that your issue can be related to the file provider in your context.

See Limitations in File | Traefik | v2.2

Middleware name not found in config (ResponseModifier)

This message appears when middleware is used on a router but it does not exist.

So I think that the problem is related to the reload of the files consumed by the file provider.
As explain in the Limitations we recommend to use directory instead of filename

1 Like

the 2 configurations works in any kind of format (TOML, YAML,labels, ...) , so your problem is not related to that.