Traefik BasicAuth Dashboard

Hi all, I am new to the forum! I have recently started using Traefik with Docker and I must say it is fantastic! The trouble I am having at the moment is when I apply basic auth middleware to my Traefik dashboard and then go to load the dashboard, it constantly prompts for my the username and password on an endless loop and I can never get to the dashboard. However, it works perfectly fine without the basic auth and I can load my dashboard just fine. Please can anyone help with this? It has been driving me crazy for the last few days. Please see my samples below. (Note for the password hash I have tried both with and without an extra dollar sign at the beginning and neither work). Thank you in advance.

My Docker Compose file:

version: '3'
    image: "traefik:v2.2"
      - "80:80"
      - "443:443"
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/user/traefik/traefik.yml:/etc/traefik/traefik.yaml:ro
      - "traefik.enable=true"
      - "traefik.http.routers.api.rule=Host(``)"
      - "traefik.http.routers.api.entrypoints=insecure"
      - "traefik.http.routers.api.service=api@internal"
      - "traefik.http.routers.api.middlewares=api-auth"
      - "traefik.http.middlewares.api-auth.basicauth.users=admin:$..."
      name: "web"

My Traefik.yml file

    endpoint: "unix:///var/run/docker.sock"
    network: "web" # Custom docker network
    exposedByDefault: false 

    address: ":80"
    address: ":443"

  dashboard: true

It may be as simple as the the type of htpasswd you generated not playing nicely with Traefik. Try generating a SHA1 password set here
and use it in place of the htpasswd you've been trying. If that doesn't work, you should follow the guidance to set basic-auth as a middlewares (check out the basic and advanced guides for Traefik v2 from containeroo on so you can check its status on Traefik dash before applying it to Traefik.

Another thing you may want to try is leaving the basic-auth off the Traefik dash but spin up something else easy like Librespeed and apply basic-auth to that container instead. If it doesn't work there then at least you'll be able to look at the instantiated basic-auth for Librespeed in the Traefik dash to see what's going on with it.

Best of luck. It's an awesome program and you are only just scratching the surface right now with how streamlined you can make the setup.

Welcome to the Community Dan!

docker compose parses the string literal you've provided in labels and will try to reference ${char}. Escape any $ by prepending another $ to it. For example:


should look like this:

Hope this makes sense.



@notsureifkevin thank you! That was indeed the issue as I did have a couple more $ characters in the password has that needed to be escaped

1 Like

@GregG thank you for the input and suggestion as it turns out I needed to escape a couple more $ characters in my passsword has