1. Caddy version (caddy version
):
v2.2.1 h1:Q62GWHMtztnvyRU+KPOpw6fNfeCD3SkwH7SfT1Tgt2c=
2. How I run Caddy:
caddy run
a. System environment:
ubuntu 18.04
b. Command:
c. Service/unit/compose file:
d. My complete Caddyfile or JSON config:
mysite.com {
root * /srv/html
file_server
}
3. The problem I’m having:
My customer sends our their URLs on print materials with capitals. I need URL paths to be assumed to be all lowercase. Would appreciate any help the community can offer with how to configure this using Caddyfile.
I’m having trouble finding an answer because there was a v1 bug related to capitalization and anything I find seems to be related to that.
4. Error messages and/or full log output:
5. What I already tried:
6. Links to relevant resources:
When I try
redir /Research /research
for example… I get a redirect loop
So I have no idea how to address the issue as of now
matt
(Matt Holt)
October 22, 2020, 9:00pm
3
Caddy’s path matcher is case-insensitive:
// Provision lower-cases the paths in m to ensure case-insensitive matching.
func (m MatchPath) Provision(_ caddy.Context) error {
for i := range m {
m[i] = strings.ToLower(m[i])
}
return nil
}
// Match returns true if r matches m.
func (m MatchPath) Match(r *http.Request) bool {
lowerPath := strings.ToLower(r.URL.Path)
// see #2917; Windows ignores trailing dots and spaces
// when accessing files (sigh), potentially causing a
// security risk (cry) if PHP files end up being served
// as static files, exposing the source code, instead of
// being matched by *.php to be treated as PHP scripts
lowerPath = strings.TrimRight(lowerPath, ". ")
repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
But you can use a regexp matcher for a case-sensitive match: Request matchers (Caddyfile) — Caddy Documentation
So I should not be experiencing this behavior?
mysite.com {
root * /srv/html/
file_server
}
/srv/html/research/index.html
curl https://mysite.com/research/
200
curl https://mysite.com/Research/
404
matt
(Matt Holt)
October 23, 2020, 1:38am
5
Well, can it be found? What does ls -la /srv/html/Research
output?
system
(system)
Closed
November 21, 2020, 7:31pm
6
This topic was automatically closed after 30 days. New replies are no longer allowed.