BasicAuth Error

Hey,

I'm curretly transforming from docker to file provider to get a more structured overview. In this process I stumbled upon the BasicAuth middleware, which is not working for me anymore. I'm using Traefik 2.2.0.

I created the user password token as the following:

echo $(htpasswd -nbB user "password") | sed -e s/\\$/\\$\\$/g # user:$$2y$$05$$/y/x10aXefWaplC44ccSwOCjOEqBivNs9GKRAleKWCIPnXmCzKHrS

If I load everything in I dont get any errors in the Traefik logs and I can also go to the dashboard but it keeps asking me for the password. Even if I type it in correctly.

Is there a mistake in my config? :confused:

# /etc/traefik/traefik.yml

entryPoints:
  http:
    address: :80
  https:
    address: :443

certificatesResolvers:
  letsEncrypt:
    acme:
      email: redacted
      storage: /etc/traefik/acme/acme.json
      dnsChallenge:
        provider: cloudflare
        delayBeforeCheck: 0

api:
  dashboard: true

providers:
  docker:
    endpoint: unix:///var/run/docker.sock
    exposedByDefault: false
  file:
    directory: /etc/traefik/dynamic/
    watch: true
# /etc/traefik/dynamic/dashboard.yml

http:
  routers:
    dashboard:
      entryPoints:
        - https
      rule: "Host(`admin.example.com`)"
      service: api@internal # This is the defined name for api. You cannot change it.
      tls:
        certResolver: letsEncrypt
        domains:
          - main: "admin.example.com"
      middlewares:
        - authtraefik
        - compress
# /etc/traefik/dynamic/traefik-dashboard-auth.yml

http:
  middlewares:
    authtraefik:
      basicAuth:
        removeheader: true
        realm: "traefik-dashboard"
        users:
          - "user:$$2y$$05$$/y/x10aXefWaplC44ccSwOCjOEqBivNs9GKRAleKWCIPnXmCzKHrS"

Hello,

this command is for the docker provider (need to escape $ with $), but if you are using the file provider you don't need to escape the $

As you are using the Docker provider, I recommend to not use the file provider to create routing.

Recommend read:

Thank you. Now it's working. :slightly_smiling_face:

Regarding the provider I wanted to test the file provider to provide better overview. I didn't wanted to bloat my docker-compose.yml file.