-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Short version: The ability to use placeholders with env
to lookup different ENV based on placeholder value at the time, or a CEL function for matchers to accomplish the same.
From what I understand (at least with Caddyfile support), an explicit ENV var can be used and is parsed with the Caddyfile, or env
placeholder can be used, similar to file
that does a lookup at runtime via method instead.
Snippets can be used with args to compose the value for env
or file
, but the inputs must be known at the time, you could not use vars
or path
placeholders for example.
My use case was for matching against content sourced from an ENV, but with:
- The ENV itself dependent upon another placeholder such as
{path.0}.upperAscii()
,{re.1}
, etc. - Composition of that ENV with a suffix for variant queries.
This could be achieved either via a CEL equivalent method where the value can be provided as a string using CEL like the above path example, or if the existing placeholder support could handle {env.{vars.example}}
.
I haven't tried with map directive yet, but expect that would be a similar issue. Presumably the only option with Caddy for this right now is snippets and creating an import
with args for each permutation upfront. Alternatively writing a custom caddy plugin or a separate service to perform the check (to allow or deny a route).
The intent was to leverage caddy's existing features in a way that a docker image could be deployed and users only needed to manage some permissions via ENV (such as for path_regexp
matchers to refer to).