Per your explicit in-person permission to bypass the template :P
It would be nice to set folders like this
browse /imgs/garden/
browse /imgs/porch-swing/
browse /imgs/arcade-cabinet/
or like this
file_server /imgs/garden /imgs/porch-swing /imgs/arcade-cabinet {
browse
}
Ah, I just remembered, you can use the matcher directive to specify all your paths in one:
matcher browseable {
path imgs/garden /imgs/porch-swing /imgs/arcade-cabinet
}
file_server match:browseable browse
Or one per line:
matcher browseable {
path imgs/garden \
/imgs/porch-swing \
/imgs/arcade-cabinet
}
file_server match:browseable browse
Is that satisfactory? I'd prefer just using this if that's okay. 馃槄
(Make sure to add another file_server directive if you just want a regular file server for everything else.)
Since I only serve one browsable path, I did:
file_server /md browse
file_server
Using the following match block throws an error
matcher browseable {
path /imgs/garden \
/imgs/porch-swing \
/imgs/arcade-cabinet
}
file_server match:browseable browse
2019/09/27 14:20:27 adapting config using caddyfile: getting matcher module '/imgs/porch-swing': module not registered: http.matchers./imgs/porch-swing
md5-382338cb376a0c685346d8a410cc60bc
matcher browseable {
path /imgs/garden /imgs/porch-swing /imgs/arcade-cabinet
}
file_server match:browseable browse
@Henrocker Ah, true, that could also work, for easy one-liners. I didn't think of that. 馃槄
@pgporada There's a wee bug in the lexer (escaping newlines is kind of a new thing), so I'm fixing that now and adding a test case for it. Stay tuned!
Just pushed commit c12bf40 which fixes escaped newlines in the Caddyfile.
I still like @Henrocker's solution:
file_server /imgs/garden browse
file_server /imgs/porch-swing browse
file_server /imgs/arcade-cabinet browse
file_server
Is that acceptable for you @pgporada?
A separate browse directive like v1 has is possible, but kinda complicated and has limited flexibility.
Closing, since I believe this is resolved! Feel free to continue the conversation if needed though.
Hi @mholt, idk when this happened but with the latest v2 and the following config:
V2: CONFIG
hnrk.io, www.hnrk.io {
root * /etc/caddy/html
tls /path/to/cert /path/to/key
encode brotli zstd gzip
php_fastcgi unix//run/php/php7.3-fpm.sock
file_server /md browse
file_server
}
browsing a specific directory using this method no longer works (I receive 404). Website is live, so you can see the current behaviour.
Is there now a specific way to configure file browsing with Caddy v2?
Thanks!
@Henrocker Using which version, exactly? Beta 12 or are you building from source.
I've built Caddy v2 from source (including 372540f)
@Henrocker path matching is no longer prefix by default; please see #2981.
Ahh thank you! Adding a '*' after /md solved it.
My config looks like this now:
V2: CONFIG
hnrk.io, www.hnrk.io {
root * /etc/caddy/html
tls /path/to/cert /path/to/key
encode brotli zstd gzip
php_fastcgi unix//run/php/php7.3-fpm.sock
file_server /md* browse
file_server
}