Problem with basicAuth middleware

Hello,

I've a problem with basicAuth middleware, and i don't found why.

docker-compose.yml :

traefik:
    image: traefik:2.9
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: ingress
      - target: 443
        published: 443
        protocol: tcp
        mode: ingress
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/debian/docker/traefik/certs/:/certs/
      - /home/debian/docker/traefik/config/traefik.toml:/etc/traefik/traefik.toml
    deploy:
      restart_policy:
        condition: on-failure
      labels:
        - traefik.enable=true
        - traefik.http.services.traefik.loadbalancer.server.port=3579
        - traefik.http.routers.traefik-http.entrypoints=web
        - traefik.http.routers.traefik-http.rule=Host(`URL`)
        - traefik.http.routers.traefik-https.entrypoints=websecure
        - traefik.http.routers.traefik-https.rule=Host(`URL`)
        - traefik.http.routers.traefik-https.tls=true
        - traefik.http.routers.traefik-https.tls.certresolver=letsencrypt
        - traefik.http.middlewares.redirect-https.redirectscheme.scheme=https
        - traefik.http.routers.traefik-http.middlewares=redirect-https@docker
        - traefik.http.routers.traefik-https.middlewares=adminauth
        - traefik.docker.network=traefik_dmz
    networks:
      - dmz

traefik.toml :

[api]
  dashboard = true
  insecure = true

[entryPoints]
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.forwardedHeaders]
      insecure = true

  [entryPoints.websecure]
    address = ":443"
    [entryPoints.websecure.forwardedHeaders]
      insecure = true

  [entryPoints.traefik]
    address = ":3579"

[providers]
  [providers.docker]
    endpoint = "unix:///var/run/docker.sock"
    exposedByDefault = false 
    swarmMode = true
  [providers.file]
    filename = "/certs/certs.toml"

[ping]
 entryPoint = "traefik"

[certificatesResolvers.letsencrypt.acme]
  email = "MAIL"
  storage = "/data/acme.json"
  caServer = "https://acme-v02.api.letsencrypt.org/directory"
  keyType = "EC256"
  [certificatesResolvers.letsencrypt.acme.httpChallenge]
    entryPoint = "web"

[http.middlewares]
  [http.middlewares.adminauth.basicAuth]
  users = [
    "admin:$apr1$kA5XWB6X$orwuHGbHthKciqa8GpEHj1"
  ]

And i've this error : time="2023-03-08T10:23:34Z" level=error msg="middleware \"adminauth@docker\" does not exist" entryPointName=websecure routerName=traefik-https@docker

I hope you have all information.

Thank's

I've solved my problem by changing my configuration. I've create a file config.toml :

[http.middlewares]
  [http.middlewares.adminauth.basicAuth]
  users = [
    "admin:$apr1$kA5XWB6X$orwuHGbHthKciqa8GpEHj1"
  ]

And in my traefik.toml i add :

[providers]
  [providers.docker]
    endpoint = "unix:///var/run/docker.sock"
    exposedByDefault = false 
    swarmMode = true
  [providers.file]
    filename = "/etc/traefik/config.toml"
    watch= true**

And in my docker-compose i change :

traefik.http.routers.traefik-https.middlewares=adminauth by traefik.http.routers.traefik-https.middlewares=adminauth@file

I understand all my modification, but i don't understand why in first method the basicAuth don't work. Someone can explain ? :slight_smile:

Thanks