lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
2.85k stars 169 forks source link

basic_auth label is still being written to caddyfile as basicauth which spams logs #633

Closed brando56894 closed 1 week ago

brando56894 commented 3 months ago

Caddy recently updated the name of basicauth to _basicauth and while the former still works, it spams the logfile with tens or hundreds of messages about it. It appears that whatever magic is used to convert Docker labels to Caddy config files still interprets _basicauth as basicauth which results in a ton of log spamming as mentioned before.

Here's a section of my compose file with the updated directive name in the label

  dozzle:
    container_name: dozzle
    image: amir20/dozzle:latest
    restart: always
    environment:
      TZ: America/New_York
      DOZZLE_ENABLE_ACTIONS: true
    labels:
      caddy: dozzle.mydomain.com
      caddy.reverse_proxy: "{{upstreams 8080}}"
      caddy.basic_auth: "*"
      caddy.basic_auth.bran: '$2a$14$OzxUNUtrb9vvl9AcaBaO2.hG1QF/d6ZzFguTW70KOxwpf/QmqLJUS'
      caddy.tls.dns: 'cloudflare apikey
      caddy.tls.resolvers: '1.1.1.1'
    networks:
      - web
      - internal
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - "8080:8080"

And the resulting chunk from Caddyfile.autosave

dozzle.mydomain.com {
        basicauth * {
                bran $2a$14.hG1QF/d6ZzFguTW70KOxwpf/QmqLJUS
        }
        reverse_proxy 172.18.0.2:8080
        tls {
                dns cloudflare apikey
                resolvers 1.1.1.1
        }
}

And the resulting log spamming

2024/06/19 18:00:16.177 WARN    config.adapter.caddyfile        the 'basicauth' directive is deprecated, please use 'basic_auth' instead!
2024/06/19 18:00:16.177 WARN    config.adapter.caddyfile        the 'basicauth' directive is deprecated, please use 'basic_auth' instead!
francislavoie commented 3 months ago

Make sure all your Docker services are rebooted/recreated. Do docker compose down then docker compose up -d to make sure their labels are all refreshed.

brando56894 commented 3 months ago

I just had to redo everything for other reasons so everything is fresh and I'm still getting that warning.

malemburg commented 1 week ago

Tested with 29-alpine and things work fine, so I guess you just need to upgrade to a later version.