Caddy as a static file page

1. My Caddy version (caddy -version):

Caddy v1.0.1-0.20190527141219-14a8ffedd8d4

2. How I run Caddy:

system service

a. System environment:

debian 9

d. My complete Caddyfile:

https://public.sub.domain.com {
  root /vault/fileserver/public
}

3. The problem I’m having:

The filepath above is just a simple folder that has some files (mainly images) that I use in public links. But when I navigate to the link, I get a 404 not found. How can I get it to display a web page file/directory listing. No CSS, no formatting, just a directory listing.

4. Error messages and/or full log output:

404 Not Found

5. What I already tried:

The caddyfile above

EDIT: Im currently using GitHub - PierreZ/goStatic: A really small static web server for Docker as a docker image to accomplish my goal of a web server, but if caddy can do it, i’d rather go that route instead of using docker resources.

Have you considered the browse directive?

https://caddyserver.com/v1/docs/browse

would the browse directive allow me to continue down the directories and sub directories? or just the top level directory defined in the caddyfile.

Yes, browse will turn all indexes under the path you specify into file/directory listings. See docs:

related question, but how do I add the browse directive to my environment? All the directives I wanted were installed when caddy was first installed

Browse is a standard directive included with the base Caddy binary. Just add browse to your Caddyfile.

1 Like

@Whitestrake I added the browse directive and restarted Caddy, but I continue to get a 404

https://public.files.redacted.domain {
  browse /gvault/fileserver/public
}

EDIT: I didnt know it still needed a root path. I added this and it worked.

1 Like

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