Basicauth throws error "illegal base64 data"

1. The problem I’m having:

I’m trying to run a caddy server via docker compose with the basic auth option but getting illegal base64 data. The docs say that caddy expects a bcrypt hash instead of a base64 string as the value but it keeps complaining about base64. So confusing, it must be something wrong on my end but I can’t figure it out.

2. Error messages and/or full log output:

run: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler modules: position 0: loading module 'subroute': provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module 'authentication': provision http.handlers.authentication: loading authentication providers: module name 'http_basic': provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 0

3. Caddy version:

caddy:2.4.6-alpine

4. How I installed and ran Caddy:

Docker compose file

a. System environment:

Ubuntu 22.04 / Docker

b. Command:

docker compose up

c. Service/unit/compose file:

version: '3'

networks:
  web:
    external: true

  caddy:
    image: caddy:2.4.6-alpine
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
    ports:
      - "80:80"
      - "443:443"
    networks:
      - web

d. My complete Caddy config:

sub.example.com {
  basicauth {
    admin $2a$12$jgDv.Plbb9KoSsg0hcoby.0sHD.P2b/flDZhd1UQHAcLvWr3QxWdu
  }

  tls {
    on_demand
  }
}

You’re using an old version that didn’t support that bcrypt string format. Please upgrade to the latest version, v2.6.4

Oh right yeah… It seems that I got the version numbers wrong lol :man_facepalming:
Thanks, it all works now!

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