-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vars not expanded in path directives #6387
Comments
For ref, context from the forums https://caddy.community/t/rewriting-of-changing-url-paths/24426 The |
Hi @francislavoie - the aim is to:
For the sake of example, with the
With the
I don't believe that using a The |
Oh right. The other details is the The tricky part is we lowercase the path during the provisioning phase (at server/config start) to avoid needing to do it on every request (saving a few nanoseconds at most on each request). This means that any dynamic parts of the path don't get lowercased since it happens before replacing the placeholders. This also means that the placeholder itself must also be lowercase 😬 so you can't have uppercase characters in the placeholder/variable name 🤦♂️ I'd call this part a bug. Obviously the only fix is to move the lowercasing to after replacing any placeholders, which would be a slight performance hit for everyone even if they don't use placeholders. Or in provisioning we could do a smarter lowercase to only lowercase parts not within placeholders, but I dunno. /cc @mholt a decision needs to be made here |
Hmmmm - this is interesting - as I'm guessing that would break the EDIT: This does seem to work - although obviously not ideal:
|
Yeah you'd probably have to use 2 different variables in that case I guess. Or you could change to using an expression matcher and do the string comparison yourself, something like this:
Placeholders inside a CEL expression act like a function call so they can't be inlined inside of a string, so concat needs to be used to form the path there. Simple enough though. |
This actually works perfectly. Thanks for this workaround! Gets me one step closer to moving my static site to Caddy :) Will leave this issue open though, as I believe the original config should actually work. |
I'm trying to simplify a bit of Caddyfile - and using a variable as part of the path name.
Part of the Caddyfile I'm using is as follows:
It seems like
{vars.cycle}
does not get expanded in thenot path
lines, but does work correctly in theredir
lines.Currently, with
{vars.cycle}
present, this results in an endless loop of 301 redirects.If I change the line to:
not path /xplane/charts/DAPS-2024-MAR-21/
, then everything works as expected.Caddy running via
caddy:latest
- currently:The text was updated successfully, but these errors were encountered: