mholt / caddy-webdav

WebDAV handler module for Caddy
Apache License 2.0
222 stars 23 forks source link

405 Method not allowed on default configuration #19

Open shural opened 3 years ago

shural commented 3 years ago

Clean download (from https://caddyserver.com/download) and installation of Caddy2+webdav on Mac OS Catalina.

Browser gets status code 405 and shows Method not allowed for https://localhost/dav, with Caddyfile extracted from Readme as below,

localhost

root * /srv

route { rewrite /dav /dav/ webdav /dav/* { prefix /dav } file_server } <<<

If replaced it with below (basically remove rewrite and prefix), everything works with http://localhost URL.

localhost root * /srv route { webdav { } file_server } <<<

Cannot find any clues anywhere :(... please kindly share any advices. Thanks.

mholt commented 3 years ago

Your browser? This is a webdav server. What is the request your browser is making?

Edit: This is probably correct, though, note the readme explains this already:

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?".

shural commented 3 years ago

I tried Chrome, and Edge. Both results are the same.

I'd like to have a prefix there for webdav, because I want to keep original file_server URL unchanged. So client/browser can access file server at https://localhost/ and access webdav at https://localhost/dav.

Another interesting finding is that, even the latter Caddyfile works (w/o prefix), a HEAD request from client will return the same 405. I do not know why, but some WebDAV client checks HEAD request as well for webdav server. Now this caddy webdav module returns 405 so basically those clients cannot work with Caddy2+webdav.

Any insights?

rickywu commented 3 years ago

try caddyfile like this

http://localhost:5001 root * /www

@notget { not method GET }

route @notget { basicauth { ricky JDJhJDE0JGlqRTI4b0ZXNExOTi5iUGdTeGJXTU9uL3JySXdaeXdLbHRIcUptdWdoLnAwNTN5ZWYySmlX } webdav }

file_server browse

oxalica commented 1 month ago

I'm still reproducing this issue on the latest caddy-webdav (with #28 merged). cc @mcieno The issue only exists when setting prefix /webdav. Remove prefix and creating sub-folders the same as prefix under root can workaround it. Would it be something wrong about prefix processing?