From f7b67f8ca1e655103bbe7a96577c88fe96f1dfb2 Mon Sep 17 00:00:00 2001 From: Solya Reka <73446919+rekacant@users.noreply.github.com> Date: Wed, 15 Sep 2021 02:23:25 +0930 Subject: [PATCH] readme: Document using file_server for GETs (#25) * Document how to server WebDAV and directory listing under same path. Thanks for help from @wader, @Zeethulhu and @noerw. * Commit suggested change https://github.com/mholt/caddy-webdav/pull/25#discussion_r692545606 Co-authored-by: Matt Holt * get, or not get Co-authored-by: Matt Holt --- README.md | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 17598cc..0eb69b9 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,7 @@ route { } ``` -The `prefix` directive is optional but has to be used if a webdav share is used in -combination with matchers or path manipulations. This is because webdav uses -absolute paths in its response. There exist a similar issue when using reverse -proxies, see -[The "subfolder problem", OR, "why can't I reverse proxy my app into a subfolder?"](https://caddy.community/t/the-subfolder-problem-or-why-cant-i-reverse-proxy-my-app-into-a-subfolder/8575). +The `prefix` directive is optional but has to be used if a webdav share is used in combination with matchers or path manipulations. This is because webdav uses absolute paths in its response. There exist a similar issue when using reverse proxies, see [The "subfolder problem", OR, "why can't I reverse proxy my app into a subfolder?"](https://caddy.community/t/the-subfolder-problem-or-why-cant-i-reverse-proxy-my-app-into-a-subfolder/8575). ``` webdav /some/path/match/* { @@ -51,6 +47,36 @@ webdav /some/path/match/* { } ``` +If you want to serve WebDAV and directory listing under same path (similar behaviour as in Apache and Nginx), you may use [Request Matchers](https://caddyserver.com/docs/caddyfile/matchers) to filter out GET requests and pass those to [file_server](https://caddyserver.com/docs/caddyfile/directives/file_server). + +Example with authenticated WebDAV and directory listing under the same path: + +``` +@get method GET + +route { + basicauth { + username hashed_password_base64 + } + file_server @get browse + webdav +} +``` + +Or, if you want to create a public listing, but keep WebDAV behind authentication: + +``` +@notget not method GET + +route @notget { + basicauth { + username hashed_password_base64 + } + webdav +} +file_server browse +``` + ## Credit Special thanks to @hacdias for making caddy-webdav for Caddy 1, from which this work is derived: https://github.com/hacdias/caddy-webdav