1. The problem I’m having:
Use Caddyfile to add header in handle_response section of reverse_proxy but adapter rejects the configuration.
2. Error messages and/or full log output:
Error: parsing caddyfile tokens for 'reverse_proxy': unrecognized directive: header_down - are you sure your Caddyfile structure (nesting and braces) is correct?, at /etc/caddy/Caddyfile:15
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
curl -1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/gpg.key’ | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt’ | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
a. System environment:
Ubuntu 24.04 in WSL2
b. Command:
caddy adapt --adapter="caddyfile" --config="/etc/caddy/Caddyfile" --pretty --validate
c. Service/unit/compose file:
not relevant
d. My complete Caddy config:
{
debug
}
:3001 {
log {
output file /var/log/caddy/year2024-access.log
}
reverse_proxy localhost:3000 {
@setcookie header Set-Cookie *
handle_response @setcookie {
header_down +X-Some-Header-Down {rp.header.Set-Cookie}
copy_response_headers
}
}
}