# \[SOLVED\] Dashboard 404 after switching to usersFile for basic auth

**URL:** <https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [August 13, 2020, 10:44pm UTC](https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292 "2020-08-13T22:44:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shot](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/shot/32/2312_2.png) [@shot](https://community.traefik.io/u/shot)\
**Post date:** [August 13, 2020, 10:44pm UTC](https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292/1 "2020-08-13T22:44:48Z")

</div>

I've got to be overlooking something very simple.Everything works perfectly if the user is added to the label directly...

```auto
- "traefik.http.middlewares.traefik-auth.basicauth.users=uname:$$ayr1$$GJr0wQ5W$$QzhuGRIckJ/zOVewa1Fei1"

```

However, referencing the same user and pw via file does not work...

```auto
- "traefik.http.middlewares.traefik-auth.basicauth.usersfile=/path/to/my/authfile"

```

The above results in a "404 page not found". I'm certain the path to the file is correct, and I've restarted all containers. Anyone have any idea what's going on?

---

<div class="post-metadata">

**Author:** ![shot](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/shot/32/2312_2.png) [@shot](https://community.traefik.io/u/shot)\
**Post date:** [August 13, 2020, 10:51pm UTC](https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292/2 "2020-08-13T22:51:38Z")

</div>

Never mind! I'm an idiot! Of course, I had to define a volume to bind-mount the silly file in the container. (Duh) 🤪

---

<div class="post-metadata">

**Author:** ![pphillips99](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/pphillips99/32/5808_2.png) [@pphillips99](https://community.traefik.io/u/pphillips99)\
**Post date:** [August 31, 2022, 1:18am UTC](https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292/3 "2022-08-31T01:18:33Z")

</div>

Thanks to shot for a push in the right direction. Had my own moment working this out as well. Gotta make that bind mount available to the `traefik` container rather than the container requiring the middleware.

```auto
version: '3'

services:

  whoami:
    image: "traefik/whoami"
    container_name: "whoami"
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker1`)"

  whoami-a:
    image: "traefik/whoami"
    container_name: "whoami-a"
    labels:
      - "traefik.http.routers.whoami-a.rule=Host(`whoami-a.docker1`)"
      # define the middleware "whoami-users"
      - "traefik.http.middlewares.whoami-users.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0"
      # tell router to use a middleware named "whoami-users"
      - "traefik.http.routers.whoami-a.middlewares=whoami-users"

  whoami-b:
    image: "traefik/whoami"
    container_name: "whoami-b"
    # this doesn't work here
    #volumes:
    # - "./usersfile.txt:/usersfile.txt:ro"
    labels:
      - "traefik.http.services.whoami-b.loadbalancer.server.port=80"
      - "traefik.http.routers.whoami-b.rule=Host(`whoami-b.docker1`)"
      # the bind mount for this file needs to be in the *traefik* container
      # define the middleware "whoami-usersfile"
      - "traefik.http.middlewares.whoami-usersfile.basicauth.usersfile=/whoami-usersfile.txt"
      # tell router to use a middleware named "whoami-usersfile"
      - "traefik.http.routers.whoami-b.middlewares=whoami-usersfile"

  traefik:
    image: traefik:v2.8.3
    command:
      - "--api.insecure=true"
      - "--providers.docker"
      - "--log.level=DEBUG"
      - "--entryPoints.http.address=:80"
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - "/home/fred/projects/whoami-b/usersfile.txt:/whoami-usersfile.txt:ro"
    labels:
      - "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.docker1`)"
      - "traefik.http.services.traefik-dashboard.loadbalancer.server.port=8080"

```

---

<div class="post-metadata">

**Author:** ![davekeeshan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/davekeeshan/32/8158_2.png) [@davekeeshan](https://community.traefik.io/u/davekeeshan)\
**Post date:** [July 22, 2024, 10:31am UTC](https://community.traefik.io/t/solved-dashboard-404-after-switching-to-usersfile-for-basic-auth/7292/4 "2024-07-22T10:31:54Z")

</div>

It would be helpful if this solution was linked or added to the [BasicAuth](https://doc.traefik.io/traefik/middlewares/http/basicauth) page
