aliases | category | classification | date | date_modified | draft | id | image | links | local_archive_links | pinned | series | tags | title | type | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
caddy |
public |
2022-12-31 06:31:23 -0800 |
2022-12-31 06:31:23 -0800 |
false |
20221231143123 |
false |
false |
|
Caddy Server Basic Authentication |
tech-note |
This will enable a prompt for a username and password when accessing the URL path. You can add additional lines for additional users.
# Template:
basicauth <path> {
<username> <password-hash>
<username> <password-hash>
<username> <password-hash>
}
# Example:
basicauth / {
jake $2a$14$piTqBgsf7igbN2FQ9fOBvusCAIYGrgSBe6sj7FaGdLQg9zJcbhzCu
}
You can't use a plaintext password, you must instead generate a hashed password. You can use Caddy's hash-password
command to do this.
Here's an example using Caddy's Docker image to hash Password123!
.
docker run --rm -it caddy:2.6.2-alpine caddy hash-password
Enter password:
Confirm password:
$2a$14$piTqBgsf7igbN2FQ9fOBvusCAIYGrgSBe6sj7FaGdLQg9zJcbhzCu