Getting Basic Auth or DigestAuth Working on a simple Whoami service

Hi All,

I'm been looking across the internet and this forum all afternoon and i can get my head around why this simple auth middleware isn't working:

services:
  reverse-proxy:
    image: traefik:v2.10
    command: 
      - --api.insecure=true 
      - --providers.docker
      - --accesslog=true
      - --log.level=DEBUG
      - "--providers.docker.exposedbydefault=false"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    profiles:
      - full
      
  whoami:
    # A container that exposes an API to show its IP address
    image: traefik/whoami
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.rule=Host(`whoami.7f000001.nip.io`)
      - traefik.http.routers.whoami.middlewares=test-auth
      - traefik.http.middlewares.test-auth.digestauth.users=test:traefik:a2688e031edb4be6a3797f3882655c05,test2:traefik:518845800f9e2bfb1f1f740ec24f074e

I'm using in other container contexts, middlewares for Http to HTTPs, Letencrypt and also IpWhitelisting, which all workied out of the box as the docs describe, but the auth middlewares i cannot get them working.

Looking at the debug logs I don't see traefik even parsing that part of the config :

reverse-proxy-1  | time="2023-11-10T15:45:45Z" level=debug msg="Configuration received: {\"http\":{\"routers\":{\"whoami\":{\"service\":\"whoami\",\"rule\":\"Host(`whoami.7f000001.nip.io`)\"}},\"services\":{\"whoami\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.22.0.2:80\"}],\"passHostHeader\":true}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

I've replicated this on a Debian 10 Server and a Docker for Windows.

Any pointers for where to look ?

1 Like