# Impossible to get basic auth for dashboard

**URL:** <https://community.traefik.io/t/impossible-to-get-basic-auth-for-dashboard/5075>\
**Category:** Traefik v2\
**Tags:** dashboard-api\
**Created:** [March 23, 2020, 8:02pm UTC](https://community.traefik.io/t/impossible-to-get-basic-auth-for-dashboard/5075 "2020-03-23T20:02:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dmg/32/1777_2.png) [@dmg](https://community.traefik.io/u/dmg)\
**Post date:** [March 23, 2020, 8:02pm UTC](https://community.traefik.io/t/impossible-to-get-basic-auth-for-dashboard/5075/1 "2020-03-23T20:02:02Z")

</div>

Hi all,

I'm totally newbie with traefik, and I have some VM for testing it. It looks great and works very well with some basic config. Now I'm trying to get some advanced settings for secure dashboard.

First step is to enable basic authentication to limit access to dashboard, but I'm gonna crazy with examples, docs, and other stuff that isn't work for me.  
**docker-compose.yml**

```auto
version: '3'

services:
  proxy:
    image: traefik:v2.1
    command:
      --api=true
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./conf:/etc/traefik
      - ./logs:/logs
      - ./ssl:/ssl
    networks:
      - proxy_default
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`domain.net`)"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.traefik.middlewares=auth"
      - traefik.http.middlewares.auth.basicauth.users=myuser:mypass"

networks:
  proxy_default:
    external: true

```

The dashboard only works if I set up **insecure=true** for api, in that case can access through [http://mydomain.net:8080](http://mydomain.net:8080)

How can I fix this? I tried config **traefik.toml** with the same labels, but not working too.

---

<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:** [March 23, 2020, 8:40pm UTC](https://community.traefik.io/t/impossible-to-get-basic-auth-for-dashboard/5075/2 "2020-03-23T20:40:35Z")

</div>

hello,

```auto
version: '3'

services:
  proxy:
    image: traefik:v2.1
    command:
      - --api
      - --providers.docker
      - --providers.docker.exposedbydefault=false
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./conf:/etc/traefik
      - ./logs:/logs
      - ./ssl:/ssl
    networks:
      - proxy_default
    labels:
      traefik.enable: true
      traefik.http.routers.dashboard.rule: Host(`domain.net`)
      traefik.http.routers.dashboard.service: api@internal
      traefik.http.routers.dashboard.middlewares: auth
      traefik.http.middlewares.auth.basicauth.users: user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/ # user/password

networks:
  proxy_default:
    external: true

```

or

```auto
version: '3'

services:
  proxy:
    image: traefik:v2.1
    command:
      - --api
      - --providers.docker
      - --providers.docker.exposedbydefault=false
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./conf:/etc/traefik
      - ./logs:/logs
      - ./ssl:/ssl
    networks:
      - proxy_default
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`domain.net`)"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.middlewares=auth"
      - "traefik.http.middlewares.auth.basicauth.users=user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/" # user/password

networks:
  proxy_default:
    external: true

```

Recommend read:

- [https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d](https://blog.containo.us/traefik-2-0-docker-101-fc2893944b9d)
- [https://github.com/containous/blog-posts/tree/master/2019\_09\_10-101\_docker](https://github.com/containous/blog-posts/tree/master/2019_09_10-101_docker)

---

<div class="post-metadata">

**Author:** ![dmg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/dmg/32/1777_2.png) [@dmg](https://community.traefik.io/u/dmg)\
**Post date:** [March 24, 2020, 9:37am UTC](https://community.traefik.io/t/impossible-to-get-basic-auth-for-dashboard/5075/3 "2020-03-24T09:37:36Z")

</div>

Thank you so much, You did it!

Extra info: I'm using dynamic dns service and the domain doesn't recognize it by traefik, I must to set on host file to get it work.
