1. The problem I’m having:
I want to require an Authorization header for a route.
But I can’t match the route with this curl:
curl -H "Authorization: 123" http://localhost:8080/abc/
401 Not authorized abc
curl -H "Authorization: 123" http://localhost:8080/def/
401 Not authorized def
What am I doing wrong?
And is there a better way to write this config?
3. Caddy version:
v2.9.0-beta.2
d. My complete Caddy config:
:8080 {
handle /abc/* {
@rbac <<CEL
(header({'Authorization': ['123']})) ||
(header({'Authorization': ['234']}))
CEL
reverse_proxy @rbac {
to server1:3000
}
respond "401 Not authorized abc" 401
}
handle /def/* {
@def {
header Authorization 123
}
reverse_proxy @def {
to server1:3000
}
respond "401 Not authorized def" 401
}
handle {
reverse_proxy {
to server1:3000
}
}
}