Traefik basic auth does not work with HTTPS

Viewed 3211

I run the service in Docker Warm Mode with these labels:

- "traefik.docker.network=proxy"
- "traefik.backend=kibana"
- "traefik.frontend.entryPoints=https,http"
- "traefik.frontend.rule=Host:mydomain"
- "traefik.port=5601"
- "traefik.frontend.auth.basic=test:098f6bcd4621d373cade4e832627b4f6"

And have this problem using HTTPS

curl -u test:test https://my-domain.com
401 Unauthorized

With HTTP all is ok

curl -u test:test http://my-domain.com
Found
3 Answers

Using htpassword solved it for me. It seems Traefik uses the same algorithm to unhash the passwords.

apt install apache2-utils

htpasswd -nb your_username "your_password_here"

You will receive the according hash

your_username:khrglahfslgkha345346

Copy paste it to your .toml or your docker-compose script.

Use your password (not the hash) for the login on your frontend and everything will work fine.

I have recently found out you have to take care of the double dollar signs in the resulting hash. You have to escape the $ in different scenarios....

I found cause of problem, I deploy service as a stack with traefik variable "traefik.frontend.auth.basic=test:$$apr1$$EaOXV0L6$DQbzuXBeb6Y8jjI2ZbGsg/". But after deploy value of this variable looks like test:/.

After manually setting correct value - auth work fine.

Also I have tried deploy service with command docker service create and variable have correct value.

Related