Common middleware settings for docker containers

Hi all,

I'm trying to have a common set of settings on traefik.yml, but I get that the middleware does not exist. How can I get some middleware settings on my traefik.yml for all my docker services, each running on a different subdomain of my host?

Error:

time="2020-05-15T18:02:11Z" level=error msg="middleware \"services@file\" does not exist" entryPointName=websecure routerName=websecure-myservice@docker

traefik.yml

entryPoints:
  web:
    address: :80
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
  websecure:
    address: :443
    http:
      middlewares:
        - services@file # also tried without @file

http:
  services:
    myServices:
      loadBalancer:
        passHostHeader: true
  middlewares:
    services:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex"
        SSLForceHost: true

providers:
  providersThrottleDuration: 2s
  docker:
    watch: true
    endpoint: unix:///var/run/docker.sock
    swarmModeRefreshSeconds: 15s

docker-compose file:

  myservice:
    image: myimage
    container_name: myservice
    hostname: myservice
    networks:
      - traefik_proxy
    labels:
      traefik.enable: "true"
      traefik.http.services.myservice.loadbalancer.server.port: 9000
      traefik.http.routers.myservice.rule: "Host(`myservice.${DOMAINNAME}`)"
      traefik.http.routers.myservice.entrypoints: "web,websecure"
      traefik.docker.network: traefik_proxy

But it does! You can use chain to reuse a set of middlewares.

You have you dynamic and static config in the same file, you cannot do that. You will want to enable the file provider and the docker provider too.