Can't get browseable file_server with request matcher to work (Caddyfile)

1. Caddy version (caddy version):

v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=

2. How I run Caddy:

With a Caddyfile

a. System environment:

Debian GNU/Linux 9 (stretch)

b. Command:

 caddy run --watch

d. My complete Caddyfile or JSON config:

mydomain.com {

        @browseable {
                path /files*
        }

        file_server @browseable browse {
                root /var/www/data/
        }
}

3. The problem I’m having:

I’m trying to use a request matcher (@browseable) to limit the file indexing capabilities of file_server to a specific path (/files*). But the only thing I get is a blank browser window… no file indexing.

4. Error messages and/or full log output:

No error messages.

5. What I already tried:

I tried various combinations of Caddyfile settings… nothing worked. Even the simplest config i could think of:

mydomain.com

root * /var/www/data/
file_server /files* browse

As soon as i try to use a matcher in combination with file_server, the file indexing is no longer working.

6. Links to relevant resources:

Hello,

I tried a few things, I think this is something like that you want (with a bonus):

mydomain.com {

  [...]  # the rest of your config

  handle /files* {
    root * /var/www/data
    file_server browse
  }

}

If I got this right : you can browse the /files path and define any physical root you want (I take the directory /var/www/data which has to contain a /files directory with all files inside).

I hope it can help!

(Wait for a confirmation as I am also a beginner :slight_smile:)

2 Likes

Hi, Alex,

thank you for your answer! The configuration you suggested works great :slight_smile:

As you correctly noted, I did not consider that the files/ path must already be part of my physical directory structure (/var/www/data/files/). D’oh!

Have a nice day and thanks again.
Werner

1 Like

Nice, have a nice day too!

Alex

Thanks for helping @dukeart!

Just curious, where does /lib and /static come from here? I don’t see it in the original question.

Hello Francis,
Oh right, I didn’t adapt my example and kept the generic names I had.
I will edit it.

Thank you for your work and support! :wink:

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