Basic Auth does not work

Hello there.
I'm trying to get basic auth working. I got it to prompt me for the auth, but its not accepting my password.
Heres my config

When trying to login, it just logs

time="2022-10-05T18:23:43Z" level=debug msg="Authentication failed" middlewareName=auth@docker middlewareType=BasicAuth

What's up?
Thanks

We use different structure in our docker-compose.yml, note "-", "="

labels:
  - 'traefik.enable=true'
  - 'traefik.http.routers.certbot.entrypoints=web'

Make sure to have a hashed password and in docker-compose.yml every single $ is escaped to $$.

Do not put a space before username. Maybe username " shorty" works?

Hey thanks for the reply. Yeah, I use that syntax in my file. I just used docker compose convert becasue I'm loading from ENV varibles so you could see how it is. The actual compose file looks like this

version: '3'

services:
  reverse-proxy:
    # The official v2 Traefik docker image
    image: traefik:v2.8
    # Enables the web UI and tells Traefik to listen to docker
    command: --providers.docker
    container_name: traefik
    ports:
      - "80:80"
      - "444:443"
    volumes:
      # So that Traefik can listen to the Docker events
      # TODO: Don't bind the full docker sock
      - /var/run/docker.sock:/var/run/docker.sock
      - type: bind
        source: ./traefik.yml
        target: /etc/traefik/traefik.yml
    restart: always
    labels:
      - "traefik.http.routers.dashboard.rule=Host(`traefik.shorty.systems`)"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.middlewares=auth"
      - "traefik.http.middlewares.auth.basicauth.users=${user}:${pass}"
      - "traefik.enable=true"
networks:
    default:
        name: traefik        

Note no space before the name. I've not escaped the $'s in my .env file, but docker compose seems to be doing it fine, and it seesm traefik got it fine, from the debug logs.

image

Thanks for your help

Ok i figured it out. Apparently .env files in docker will convert $'s if and only if they have capital letters after them. As such most of my dollar signs were working, except for one, and escaping would be needed on just one. I was able to avoid this by wrapping my thing in single quotes.
Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.