\"securityHeaders@docker\" does not exist" (same pb for 'securityHeaders@files')

Hello,
I have a traefik docker (latest) running on an Unraid server (latest).
This is a fresh install.
I have followed the config from Ibracorp.

The exact error I have today is:

time="2023-06-04T08:33:44+03:00" level=error msg="middleware \"securityHeaders@docker\" does not exist" entryPointName=https routerName=UptimeKuma@docker

My fileConfig.yml

 # Security headers
    securityHeaders:
      headers:
        customResponseHeaders:
          X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
          X-Forwarded-Proto: "https"
          server: ""
        customRequestHeaders:
          X-Forwarded-Proto: "https"
        sslProxyHeaders:
          X-Forwarded-Proto: "https"
        referrerPolicy: "same-origin"
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        contentTypeNosniff: true
        browserXssFilter: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsSeconds: 63072000
        stsPreload: true

My traefik.yml

# HTTPS endpoint, with domain wildcard
  https:
    address: :443
    forwardedHeaders:
      # Reuse list of Cloudflare Trusted IP's above for HTTPS requests
      trustedIPs: *trustedIps
    http:
      tls:
        # Generate a wildcard domain certificate
        certResolver: letsencrypt
        domains:
          - main: domain.org
            sans:
              - '*.domain.org'
      middlewares:
        - securityHeaders@file

providers:
providersThrottleDuration: 2s

Any ideas ?
Thx

Share your full Traefik static and dynamic config, and docker-compose.yml if used.

Note that your configs look a bit messed up, in yml every space can make a difference.

A similar question was asked and answered before, maybe that helps.

traefik.yml

global:
  checkNewVersion: true
  sendAnonymousUsage: false
serversTransport:
  insecureSkipVerify: true
entryPoints:
  # Not used in apps, but redirect everything from HTTP to HTTPS
  http:
    address: :80
    forwardedHeaders:
      trustedIPs: &trustedIps
        # Start of Clouflare public IP list for HTTP requests, remove this if you don't use it
        - 173.245.48.0/20
        - 103.21.244.0/22
        - 103.22.200.0/22
        - 103.31.4.0/22
        - 141.101.64.0/18
        - 108.162.192.0/18
        - 190.93.240.0/20
        - 188.114.96.0/20
        - 197.234.240.0/22
        - 198.41.128.0/17
        - 162.158.0.0/15
        - 104.16.0.0/12
        - 104.24.0.0/14
        - 172.64.0.0/13
        - 131.0.72.0/22
        - 2400:cb00::/32
        - 2606:4700::/32
        - 2803:f800::/32
        - 2405:b500::/32
        - 2405:8100::/32
        - 2a06:98c0::/29
        - 2c0f:f248::/32
        # End of Cloudlare public IP list
    http:
      redirections:
        entryPoint:
          to: https
          scheme: https
  # HTTPS endpoint, with domain wildcard
  https:
    address: :443
    forwardedHeaders:
      # Reuse list of Cloudflare Trusted IP's above for HTTPS requests
      trustedIPs: *trustedIps
    http:
      tls:
        # Generate a wildcard domain certificate
        certResolver: letsencrypt
domains:
          - main: domain.org
            sans:
              - '*.domain.org'
      middlewares:
        - securityHeaders@files
providers:
  providersThrottleDuration: 2s
  # File provider for connecting things that are outside of docker / defining middleware
  file:
    filename: /etc/traefik/fileConfig.yml
    watch: true
  # Docker provider for connecting all apps that are inside of the docker network
  docker:
    watch: true
    network: docker_network    # Add Your Docker Network Name Here
    # Default host rule to containername.domain.example
    defaultRule: "Host(`{{ lower (trimPrefix `/` .Name )}}.domains.org`)"    # Replace with your domain
    swarmModeRefreshSeconds: 15s
    exposedByDefault: false
    endpoint: "tcp://dockersocket:2375"
# Enable traefik ui
api:
  dashboard: true
  insecure: true
# Log level INFO|DEBUG|ERROR
log:
  level: INFO
# Use letsencrypt to generate ssl cerficiates
certificatesResolvers:
  letsencrypt:
    acme:
      email: traefik_certif@xxxxxxxx
      storage: /etc/traefik/acme.json
      dnsChallenge:
        provider: cloudflare
        # Used to make sure the dns challenge is propagated to the rights dns servers
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

fileConfig.yml

EXTERNAL ROUTING

http:
    routers:
        www:
            entryPoints:
            - https
            rule: 'Host(`www.domain.org`)'
            service: www
            middlewares:
            - "auth"

SERVICES

services:
    www:
        loadBalancer:
            servers:
            - url: http://192.1xxxxx:80/
            
                # Security headers
                securityHeaders:
                  headers:
                    customResponseHeaders:
                      X-Robots-Tag: "none,noarchive,nosnippet,notranslate,noimageindex"
                      X-Forwarded-Proto: "https"
                      server: ""
                    customRequestHeaders:
                      X-Forwarded-Proto: "https"
                    sslProxyHeaders:
                      X-Forwarded-Proto: "https"
                    referrerPolicy: "same-origin"
                    hostsProxyHeaders:
                      - "X-Forwarded-Host"
                    contentTypeNosniff: true
                    browserXssFilter: true
                    forceSTSHeader: true
                    stsIncludeSubdomains: true
                    stsSeconds: 63072000
                    stsPreload: true
            
                    tls:
                     options:
                       default:
                       minVersion: VersionTLS12
                       cipherSuites:
                    - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
                    - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
                    - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
                    - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
                    - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
                    - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305

You need to use 3 backticks in front and after code or mark the code and use the </> button.

And I think you are missing the map indicator (dash):

securityHeaders:
  headers:
    - x: 1
    - y: 2