1. Caddy version (caddy version
):
2.4.3
2. How I run Caddy:
a. System environment:
Docker, Kubernetes
b. Command:
caddy run -config /etc/caddy/Caddyfile
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
{
auto_https off
debug
admin off
}
:9080 {
route /authtest {
reverse_proxy http://localhost:8095 {
# Always GET, so that the incoming
# request's body is not consumed
method GET
# Change the URI to the auth gateway's
# verification endpoint
rewrite /ping
# Forward the original method and URI,
# since they get rewritten above; this
# is in addition to other X-Forwarded-*
# headers already set by reverse_proxy
header_up X-Forwarded-Method {method}
header_up X-Forwarded-Uri {uri}
# On a successful response, copy response headers
@good status 2xx
handle_response @good {
request_header {
# for example, for each copy_headers field...
Remote-User {rp.header.Remote-User}
Remote-Email {rp.header.Remote-Email}
}
}
}
}
}
3. The problem I’m having:
Hi,
I need to call an authentication service before I grant access to a certain url.
For this I tried the code which you can get from the forward_auth directive documentation.
The problem is that I can’t use the method or rewrite directive inside reverse_proxy altough it is listed in the syntax section for the reverse_proxy directive.
Do I have a logic/syntax error or why does my caddyfile not work ?
Thank you !
4. Error messages and/or full log output:
{"level":"info","ts":1658833923.533105,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
run: adapting config using caddyfile: parsing caddyfile tokens for 'route': /etc/caddy/Caddyfile:35 - Error during parsing: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:12 - Error during parsing: unrecognized subdirective method
5. What I already tried:
Tried to google my problem.
6. Links to relevant resources:
forward_auth (Caddyfile directive) — Caddy Documentation.
reverse_proxy (Caddyfile directive) — Caddy Documentation