Caddyfile: fix the /admin/ rewrite (matcher follows the directive)

'@admin rewrite ...' is parsed as a one-liner matcher DEFINITION, so it
re-defined @admin and Caddy rejected the config ('matcher is defined more
than once'), crash-looping the container. Per the Caddyfile matcher docs the
matcher token is the first ARGUMENT after the directive: 'rewrite @admin
/admin.html'. The '*' disambiguator is only needed pre-2.8.0. Validated the
rendered config against the porkbun image: 'Valid configuration'.
This commit is contained in:
Frank
2026-08-23 17:42:44 -07:00
parent e7eaba4457
commit 25af3d9fdf
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ dankclaw.franksdank.cloud {
basicauth @admin { basicauth @admin {
frank REPLACE_WITH_ADMIN_HASH frank REPLACE_WITH_ADMIN_HASH
} }
@admin rewrite * /admin.html rewrite @admin /admin.html
root * /srv/homepage root * /srv/homepage
file_server file_server
} }
+4 -1
View File
@@ -26,5 +26,8 @@ setup() {
} }
@test "the /admin/ path is rewritten to admin.html" { @test "the /admin/ path is rewritten to admin.html" {
grep -qE "@admin[[:space:]]+rewrite[[:space:]]+\*[[:space:]]+/admin.html" "$CADDY" # The matcher token follows the directive (rewrite @admin ...), per the
# Caddyfile matcher docs. A leading '@admin rewrite' is parsed as a
# one-liner matcher DEFINITION and re-defines @admin (invalid).
grep -qE "rewrite[[:space:]]+@admin[[:space:]]+/admin.html" "$CADDY"
} }