Middleware \"user-auth@file\" does not exist" after traefik update from 2.8.1 to higher releases

After the update from 2.8.1 to higher releases (up to the latest stable 2.8.5) error message "user-auth@file does not exist" persists. Rolling back to 2.8.1 helps to solve the issue. Obviously during the update and rolling back the corresponding file is untouched.

My configuration:

version: "3.7"

services:
  traefik:
    image: traefik:2.8.5
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    environment:
      - CF_API_EMAIL=email@gmail.com
      - CF_DNS_API_TOKEN=$TOKEN
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /home/docker/traefik/data/traefik.yml:/traefik.yml:ro
      - /home/docker/traefik/data/acme.json:/acme.json
      - /home/docker/traefik/data/dynamic.yml:/dynamic.yml:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=https"
      - "traefik.http.routers.traefik.rule=Host(`traefik.domainname.com`)"
      - "traefik.http.routers.traefik.middlewares=https-redirect@file"
      - "traefik.http.routers.traefik.middlewares=user-auth@file"
      - "traefik.http.routers.traefik.tls=true"
      - "traefik.http.routers.traefik.tls.certresolver=cloudflare"
      - "traefik.http.routers.traefik.tls.domains[0].main=*.domainname.com"
      - "traefik.http.routers.traefik.tls.domains[0].sans=domainname.com"
      - "traefik.http.routers.traefik.service=api@internal"

networks:
  proxy:
    external:
      name: proxy
  default:
    driver: bridge

Part of dynamic.yml has the below structure:

# Declaring the user list
http:
  middlewares:
    user-auth:
      basicAuth:
        users:
          - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"

Static config has following instruction where to look for a dynamic config:

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /dynamic.yml
    watch: true

Hello,

can you provide the full debug logs?

Have you checked all the content of dynamic.yml with the JSON schema of the dynamic configuration?

Note, you cannot use several time the same labels (traefik.http.routers.traefik.middlewares)

If you want to set several middlewares on one router you have to do that:

    - "traefik.http.routers.traefik.middlewares=https-redirect@file,user-auth@file"

Hello @Idez,

Many thanks for your comments! They helped me to detect the source of my issue and solve it finally!
Only today I noticed another error message that actually occurred first after I run the service:

level=error msg="Cannot start the provider *file.Provider: yaml: unmarshal errors:\n  line 40: mapping key \"contentTypeNosniff\" already defined at line 33\n  line 41: mapping key \"stsPreload\" already defined at line 36"

As a result, the service was not able to read any line after. I really don't know why I haven't noticed it before :slight_smile: I was sure that the only error messages related to the service were the ones I specified above.
Nonetheless after I analyzed my dynamic config I found several identical lines which conflicted with a more strict parsing of the dynamic configuration for "array" types (as was explained by @rtribotte here)

Thank you all for your assistance!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.