Url case sensitivity when serving files

1. Caddy version (caddy version):

Tested 2.2.0 and 2.4.0

2. How I run Caddy:

Local environment, Docker

a. System environment:

OS: MacOS 11.3.1, Ubuntu
Docker: 20.10.6 and 19.3.1

b. Command:

caddy run -config Caddyfile

c. Service/unit/compose file:

version: "3.7"

services:
  caddy:
    build: .
    restart: unless-stopped
    ports:
      - "8000:8000"
    volumes:
      - $PWD/volume/public:/usr/share/caddy

volumes:
  caddy_data:
  caddy_config:

d. My complete Caddyfile or JSON config:

Default one has the issue

3. The problem I’m having:

It looks that when serving files Caddy is case sensitive.
We have index.html in our root folder when doing
curl -sSL -D - http://domain/index.html
we get a 200 status code

When executing:
curl -sSL -D - http://domain/INDEX.html
we end up with an error described in logs.

This happens on Linux environment since MacOS file system is not case sensitive.

4. Error messages and/or full log output:

{
  "level": "error",
  "error": "{id=xsk89h02n} fileserver.(*FileServer).notFound (staticfiles.go:386): HTTP 404",
  "first_error": {
    "msg": "{id=gdp6s59j4} fileserver.(*FileServer).notFound (staticfiles.go:386): HTTP 404",
    "status": 404,
    "err_trace": "fileserver.(*FileServer).notFound (staticfiles.go:386)"
  }
}

5. What I already tried:

We tried to run:

  • Caddy outside Docker
  • Caddy on Kubernetes
    with the same result.

6. Links to relevant resources:

Looks like we’re having @ryanburnette 's same issue, reopening this.

I can confirm that this behaviour also happens to me with 2.4.0 and default config. Running on Linux Ubuntu 20.04

docker run -d -p 80:80 caddy:2.4.0
curl -I localhost:80/index.html
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 12226
Content-Type: text/html; charset=utf-8
Last-Modified: Tue, 11 May 2021 01:04:23 GMT
Server: Caddy
Date: Fri, 14 May 2021 13:19:20 GMT

curl -I localhost:80/INDEX.HTML
HTTP/1.1 404 Not Found
Server: Caddy
Date: Fri, 14 May 2021 13:19:27 GMT

It looks like Caddy is case sensitive. And this info: Paths with uppercase letters aren't working - #3 by matt does not apply here. @matt Could you confirm this?

Caddy follows the case sensitivity mode of the operating system it runs on. If you run it on Linux, then it is case sensitive.

There’s not really anything you can do about that, because a file index.html and INDEX.HTML may exist in the same directory. It would be ambiguous if a lookup was case insensitive.

And either way, we’re using Golang’s os package to find files, which follows how the underlying operating system functions, so we don’t really have an easy way to make it case insensitive.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.