Skip to content

Commit

Permalink
readme: Document using file_server for GETs (#25)
Browse files Browse the repository at this point in the history
* Document how to server WebDAV and directory listing under same path.

Thanks for help from @wader, @Zeethulhu and @noerw.

* Commit suggested change

#25 (comment)

Co-authored-by: Matt Holt <[email protected]>

* get, or not get

Co-authored-by: Matt Holt <[email protected]>
  • Loading branch information
Solya Reka and mholt authored Sep 14, 2021
1 parent c949b32 commit f7b67f8
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/* {
Expand All @@ -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

0 comments on commit f7b67f8

Please sign in to comment.