How to setup Caddy file server with disks C: D: and E: on Win10?

1. The problem I’m having:

I want Caddy to run as a file server for all disks: C:, D:\ and E:\ in Windows 10.
This is my present Caddyfile:
localhost
root * E:
file_server browse

And Caddy file server works great, for files on disk E:.

But I want other disks, namely C:\ and D:\ to be included in file share

2. Error messages and/or full log output:

Not relevant

3. Caddy version:

Caddy version 2.6.4.

4. How I installed and ran Caddy:

I installed Caddy using Install — Caddy Documentation

a. System environment:

Windows 10.

b. Command:

Not applicable.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

My Caddyfile which works well for files on disk E:\ is:
localhost
root * E:
file_server browse
Not sure why \ must be left out?

I have tried, without success, the following:
localhost {
  root * C:\
  root * E:\
  root * D:\
}
file_server browse

ALSO tried
localhost {
  root * C:
  root * E:
  root * D:
}
file_server browse

5. Links to relevant resources:

Well first you should read this:

to gain an understanding of the Caddyfile structure. You’ll notice that all directives have to be within site blocks.

I would do it this way:

localhost

file_server /c/* {
   root C:
}
file_server /d/* {
   root D:
}
file_server /e/* {
   root E:
}

If you absolutely need just 1 root (why?) you might be able to access multiple drives from a single root filepath because Windows is weird:

But I think we also reject unusual file paths for security reasons.

But it also must be said, serving your entire system drive is a terrible idea for a variety of reasons (security etc). Be very careful when doing this.

Thank you,
suggest way does not include “browse”, how to include it?
I tried

localhost

file_server browse /c/* {
   root C:
}
file_server browse /d/* {
   root D:
}
file_server browse /e/* {
   root E:
}

but I gets error when starting caddy.

What error?

And just add “browse” inside the file_server blocks.

But be aware that anyone that can access your server can now read all the files on your OS (that Caddy has permission to read, at least).

This record in Caddyfile:

localhost
file_server /c/* {
root C:
}

produces blank HTML page. However, Caddy web server starts. I get this error:
Caddyfile input is not formatted; run the ‘caddy fmt’ command to fix inconsistencies {“adapter”: “caddyfile”, “file”: “Caddyfile”, “line”: 3}

That’s not an error, that’s just a warning.

Show a request with curl -v. Enable the debug global option and look at your logs. Please review the structure of the Caddyfile: Caddyfile Concepts — Caddy Documentation

Are these even the correct paths? Windows would treat them as relative ones without the leading backslash.

C:\ would describe the filesystem root as an absolute path. C: would refer to the current directy within C.

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