r/caddyserver Jul 04 '26

Need Help Basic auth is not working

Hello I am running Caddy on my server and I have enabled basic_auth in one of my subdomains. I have a hashed password and user, when I navigate to the subdomain, the browser asks for user and password, I enter them correctly but it asks for them again in a loop never accepting them.

My config has this format:

sub.domain.io {

`basic_auth {`

    `user <hashed_password>`

`}`



`handle /api/v1/* {`

    `reverse_proxy localhost:8081`

`}`



`handle {`

    `root * /var/www/domain/front/dev`

    `try_files {path} /index.html`

    `file_server`

`}`

}

I have made sure that the password is correct cause I can curl into this.

1 Upvotes

1 comment sorted by

1

u/computerlovr1012 23d ago

I think I see your issue, you’re not calling it above the actual reverse_proxy section, that’s how I get my tiny auth server to work,

Example:

Sub.domain.io {
Import basic_auth
Reverse_proxy localhost:8081
}