Skip to content
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

feat(caddy): upgrade to Caddy 2.9.0 #1302

Merged
merged 2 commits into from
Jan 6, 2025
Merged

feat(caddy): upgrade to Caddy 2.9.0 #1302

merged 2 commits into from
Jan 6, 2025

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Jan 5, 2025

Upgrade to Caddy 2.9 and leverage the new first_exist_fallback try policy (caddyserver/caddy#6699).

@dunglas dunglas merged commit c2ca4db into main Jan 6, 2025
52 of 55 checks passed
@dunglas dunglas deleted the feat/caddy-2.9 branch January 6, 2025 12:34
@AlliBalliBaba
Copy link
Collaborator

@dunglas I noticed that this block will also cause a file access on every request even though its only purpose is to redirect on directory index files from /path -> /path/ (the 'canonical' path). Not sure how to optimize this, but it would be another opportunity to minimize file access.

frankenphp/caddy/caddy.go

Lines 559 to 582 in c2ca4db

if dirRedir {
redirMatcherSet := caddy.ModuleMap{
"file": h.JSON(fileserver.MatchFile{
TryFiles: []string{dirIndex},
}),
"not": h.JSON(caddyhttp.MatchNot{
MatcherSetsRaw: []caddy.ModuleMap{
{
"path": h.JSON(caddyhttp.MatchPath{"*/"}),
},
},
}),
}
redirHandler := caddyhttp.StaticResponse{
StatusCode: caddyhttp.WeakString(strconv.Itoa(http.StatusPermanentRedirect)),
Headers: http.Header{"Location": []string{"{http.request.orig_uri.path}/"}},
}
redirRoute := caddyhttp.Route{
MatcherSetsRaw: []caddy.ModuleMap{redirMatcherSet},
HandlersRaw: []json.RawMessage{caddyconfig.JSONModuleObject(redirHandler, "handler", "static_response", nil)},
}
routes = append(routes, redirRoute)
}

image

@dunglas
Copy link
Owner Author

dunglas commented Jan 6, 2025

Yes, I already discussed this one with @francislavoie but I'm not sure we can find a generic solution to prevent it.

The best we can do is probably some custom config like this one, or to introduce a cache. https://github.com/dunglas/symfony-docker/blob/main/frankenphp/Caddyfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants