Skip to content

Latest commit

 

History

History
49 lines (41 loc) · 1.11 KB

caddy-authentication.md

File metadata and controls

49 lines (41 loc) · 1.11 KB
aliases category classification date date_modified draft id image links local_archive_links pinned print series tags title type
caddy-authentication
caddy
public
2022-12-31 06:31:23 -0800
2022-12-31 06:31:23 -0800
false
20221231143123
false
false
caddy
authentication
basic-authentication
hash
Caddy Server Basic Authentication
tech-note

Basic Authentication

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