# Problem with basicAuth middleware

**URL:** <https://community.traefik.io/t/problem-with-basicauth-middleware/17830>\
**Category:** Traefik v2\
**Tags:** docker, docker-swarm, middleware\
**Created:** [March 8, 2023, 10:38am UTC](https://community.traefik.io/t/problem-with-basicauth-middleware/17830 "2023-03-08T10:38:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yguerchet](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/yguerchet/32/6777_2.png) [@yguerchet](https://community.traefik.io/u/yguerchet)\
**Post date:** [March 8, 2023, 10:38am UTC](https://community.traefik.io/t/problem-with-basicauth-middleware/17830/1 "2023-03-08T10:38:19Z")

</div>

Hello,

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

**docker-compose.yml :**

```auto
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 :**

```auto
[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

---

<div class="post-metadata">

**Author:** ![yguerchet](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/yguerchet/32/6777_2.png) [@yguerchet](https://community.traefik.io/u/yguerchet)\
**Post date:** [March 8, 2023, 11:15am UTC](https://community.traefik.io/t/problem-with-basicauth-middleware/17830/2 "2023-03-08T11:15:03Z")

</div>

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

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

```

And in my traefik.toml i add :

```auto
[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 ? 🙂

Thanks
