# Dashboard Auth not working

**URL:** <https://community.traefik.io/t/dashboard-auth-not-working/7249>\
**Category:** Traefik v2\
**Tags:** dashboard-api\
**Created:** [August 9, 2020, 2:50pm UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249 "2020-08-09T14:50:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![darox](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/darox/32/2431_2.png) [@darox](https://community.traefik.io/u/darox)\
**Post date:** [August 9, 2020, 2:50pm UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/1 "2020-08-09T14:50:19Z")

</div>

I recently started to use Traefik and to play around. I'd like to add auth to the dashboard. My docker-compose.yaml is:

```auto
version: '3'

services:
  reverse-proxy:
    image: traefik:v2.2
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock 
      - ${PWD}/traefik.toml:/traefik.toml  
  whoami:
    image: containous/whoami
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"

```

And my traefik.toml:

```auto
[log]
  level = "DEBUG"

[global]
  checkNewVersion = true
  sendAnonymousUsage = false

[providers.docker]

[api]
  #insecure = true
  dashboard = true
  debug = true

[entryPoints]
  [entryPoints.http]
  address = ":80"

[http.routers.my-api]
  rule = "Host(`traefik.damn.li`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
  service = "api@internal"
  middlewares = ["auth"]

[http.middlewares.auth.basicAuth]
  users = [
  "dario:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
]

```

When I go to traefik.damn.li I get 404 Not found. Did I miss something in the docs or why can't I access the dashboard?

Thank you

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [August 9, 2020, 10:25pm UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/2 "2020-08-09T22:25:48Z")

</div>

I suggest you verify first it's working _without_ the auth. The when you are happy with that add the auth. It seems that your host rule would not match `traefik.damn.li/`

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [August 9, 2020, 11:15pm UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/3 "2020-08-09T23:15:07Z")

</div>

in the v2, the [dynamic configuration](https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-dynamic-configuration) and the [static configuration](https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-static-configuration) must be defined in separated files:

- [https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-dynamic-configuration](https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-dynamic-configuration)
- [https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-static-configuration](https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-static-configuration)

* * *

> **without files**
>
> docker-compose.yml:
> 
> ```auto
> version: '3.7'
> 
> services:
> 
> reverse-proxy:
> image: traefik:v2.2.7
> command:
> - --log.level=DEBUG
> - --global.checkNewVersion
> - --api
> - --providers.docker
> - --entrypoints.web.address=:80
> ports:
> - "80:80"
> volumes:
> - /var/run/docker.sock:/var/run/docker.sock
> labels:
> traefik.enable: "true"
> 
> # Dashboard
> traefik.http.routers.traefik.rule: Host(`traefik.damn.li`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
> traefik.http.routers.traefik.entrypoints: websecure
> traefik.http.routers.traefik.service: api@internal
> traefik.http.routers.traefik.middlewares: auth
>       
> traefik.http.middlewares.auth.headers.basicAuth.users: dario:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/
> 
> whoami:
> image: containous/whoami
> labels:
> traefik.http.routers.whoami.rule: Host(`whoami.docker.localhost`)
> 
> ```

> **with files**
>
> docker-compose.yml:
> 
> ```auto
> version: '3.7'
> 
> services:
> 
> reverse-proxy:
> image: traefik:v2.2.7
> ports:
> - "80:80"
> volumes:
> - /var/run/docker.sock:/var/run/docker.sock
> - ${PWD}/traefik.toml:/traefik.toml
> - ${PWD}/dyn/:/dyn/
> 
> whoami:
> image: containous/whoami
> labels:
> traefik.http.routers.whoami.rule: Host(`whoami.docker.localhost`)
> 
> ```
> 
> traefik.toml:
> 
> ```auto
> [log]
> level = "DEBUG"
> 
> [global]
> checkNewVersion = true
> sendAnonymousUsage = false
> 
> [providers.docker]
> 
> [providers.file]
> directory = "/dyn/"
> watch = true
> 
> [api]
> dashboard = true
> 
> [entryPoints]
> [entryPoints.http]
> address = ":80"
> 
> ```
> 
> /dyn/config.toml
> 
> ```auto
> [http.routers.my-api]
> rule = "Host(`traefik.damn.li`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
> service = "api@internal"
> middlewares = ["auth"]
> 
> [http.middlewares.auth.basicAuth]
> users = [
> "dario:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
> ]
> 
> ```

---

<div class="post-metadata">

**Author:** ![darox](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/darox/32/2431_2.png) [@darox](https://community.traefik.io/u/darox)\
**Post date:** [August 10, 2020, 11:31am UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/4 "2020-08-10T11:31:43Z")

</div>

Do you mean dynamic via labels in docker compose and static via traefik.toml?

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [August 10, 2020, 11:46am UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/5 "2020-08-10T11:46:11Z")

</div>

I mean that:

- you cannot use the same file for static and dynamic configuration
- to use a file as a source of dynamic configuration, you have to enable the file provider

FYI, the dynamic configuration can be defined in different ways: file, labels, ...

Take a look to my previous examples.

---

<div class="post-metadata">

**Author:** ![tokynet](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tokynet](https://community.traefik.io/u/tokynet)\
**Post date:** [August 13, 2020, 6:25pm UTC](https://community.traefik.io/t/dashboard-auth-not-working/7249/6 "2020-08-13T18:25:03Z")

</div>

Not sure if you figured this out or not... but I do suggest you do get it working w/o Auth and then you take that dive into middlewares etc.

Also, this block should be defined in your docker-compose as labels.

> [@darox](#):
>
> ```auto
> [http.routers.my-api]
> rule = "Host(`traefik.damn.li`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
> service = "api@internal"
> middlewares = ["auth"]
> 
> ```
