File_server root not serving correct folder

1. The problem I’m having:

I’m trying to use the file_server directive, but it’s not going well at all.

Here’s my Caddyfile

root * /static/

My folder structure looks like this:

  - index.html
      - style.css

2. Error messages and/or full log output:

It starts the file server, but when I go to localhost:2019 it just shows me 404 Not Found. The request is being shown in the Caddy console. Changing this to localhost:2019/index.html also doesn’t change anything.

2023/07/03 21:52:37.212 INFO    admin.api       received request        {"method": "GET", "host": "localhost:2019", "uri": "/", "remote_ip": "", "remote_port": "57197", "headers": {"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.5"],"Connection":["keep-alive"],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0"]}}

3. Caddy version:


4. How I ran Caddy:

caddy run from the actual root folder. Parent of static/


Windows 10 19045

You configured your site address as, which will only have Caddy handle requests with the Host header having, on port 443.

localhost:2019 is Caddy’s admin endpoint, that’s not where your site is hosted.

Change your site address to :80 to have Caddy handle any request to port 80 for your file server

Are you sure you didn’t mean to do root * static/ ? The difference is that you used /static which is an absolute path, i.e. a directory called static at the root of your filesystem, not relative to where you ran the command.

Nice this fixed it! Thank you very much.

This was one of the many things I tried (I probably should have specified it in my issue). So the main issue seems to have been with the address, but yes, the path would also have been wrong in the config I shared.

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