Hi guys,
using Caddy v2.6.4. I wonder how I can use multiple named matchers with the same handler. Here is what I tried:
example.com {
@api_access1 {
method PATCH
header X-API-Key test1
path /api/v1/aaa
}
@api_access2 {
method PATCH
header X-API-Key test2
path /api/v1/bbb
}
handle @api_access1 @api_access2 {
reverse_proxy http://backend {
header_up X-API-Key top-secret
}
}
}
Fails with: “Error: adapting config using caddyfile: parsing caddyfile tokens for ‘handle’: /etc/caddy/Caddyfile:14 - Error during parsing: Wrong argument count or unexpected line ending after ‘@api_access2’”
2,.
example.com {
@api_access1 {
method PATCH
header X-API-Key test1
path /api/v1/aaa
}
@api_access2 {
method PATCH
header X-API-Key test2
path /api/v1/bbb
}
@api_access {
expression @api_access1 or @api_access2
}
handle @api_access {
reverse_proxy http://backend {
header_up X-API-Key top-secret
}
}
}
Fails with: “Error: loading initial config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 0: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading matcher modules: module name ‘expression’: provision http.matchers.expression: compiling CEL program: ERROR: :1:1: Syntax error: token recognition error at: ‘@’”
(bla) {
handle {args[0]} {
reverse_proxy http://backend {
header_up X-API-Key top-secret
}
}
}
example.com {
@api_access1 {
method PATCH
header X-API-Key test1
path /api/v1/aaa
}
import bla @api_access1
@api_access2 {
method PATCH
header X-API-Key test2
path /api/v1/bbb
}
import bla @api_access2
}
Fails with: “Error: adapting config using caddyfile: parsing caddyfile tokens for ‘handle’: /etc/caddy/Caddyfile:2 - Error during parsing: Wrong argument count or unexpected line ending after ‘{args[0]}’”
Any idea how to get this working in a simple way without duplication? Thank you