mholt / caddy-webdav

WebDAV handler module for Caddy
Apache License 2.0
228 stars 24 forks source link

Webdav with Jetbrains Rider, Caddy and ASP NET Core Umbraco CMS #36

Open DanielOberlechner opened 1 year ago

DanielOberlechner commented 1 year ago

Hi, I have these settings as default in webdav:

danobe.dev {
        # Set this path to your site's directory.
        #root * /usr/share/caddy

        # Enable the static file server.
        #file_server

        # Another common task is to set up a reverse proxy:
        reverse_proxy localhost:5000

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

I tried by know all different choices with webdav and tutorials in the internet, but I can't get it to work.

Bildschirmfoto 2023-08-12 um 12 06 40

This are the fields I have to enter in the image. I'm not really familiar with webdav, it seems to be the only convinient way to deploy my application.

I have a linux server with the path /var/www/personalWebsite into which I would like to deploy my application.

It works via scp and rsync but it looks like I'm to dumb to get it to work with debdav.

Could you provide a clear explanation on how I have to change the caddy configuration file?

Like I've said I tried all possible combinations but I couldn't get it to work...

And how do I restrict the access, is this like a public ftp where everyone can deploy files? I've read this here, and here it get's shown I have to create a password hash, but I don't know if this is necessary? https://marko.euptera.com/posts/caddy-webdav.html

That would be very kind of you, kind regards greets from Italy, Daniel

mholt commented 1 year ago

Hi Daniel, I'm sorry to say I don't actually know much about this setup. What errors are you getting?

I've read this here, and here it get's shown I have to create a password hash, but I don't know if this is necessary?

It's recommended to use some form of authentication if you're enabling this on a public network interface, yes. basicauth is probably the easiest way to do it. This docs page can help: https://caddyserver.com/docs/caddyfile/directives/basicauth

DanielOberlechner commented 1 year ago

Hi @mholt, thank you for answering!

I got the message: "Unknown message with code webdav.danobe.dev:6180 failed to respond"

This is my Caddy config:

{
        order webdav before file_server
}

webdav.danobe.dev:6180 {
        root * /webdav
        basicauth {
                user $2a$14$9SMz8Yufvqjm03TuaBvesecPC9/pnE11hQh3YpLUkMG8XCP2Sr4GG
        }
        webdav
}

Ports are open and forwarded...

Any suggestions on how to fix or what I do wrong?

Kind regards, Daniel Oberlechner

wader commented 1 year ago

Hi, i would probably try without auth just to make sure then look into if prefix is needed. Looking at the above screenshot i suspect you might want prefix /dav? see the documentation about prefix for details

DanielOberlechner commented 1 year ago

webdav.danobe.dev:6180 {
        #root /webdav
        basicauth {
                user $2a$14$9SMz8Yufvqjm03TuaBvesecPC9/pnE11hQh3YpLUkMG8XCP2Sr4GG
        }
        webdav {
                root /webdav
                #prefix /webdav
        }
        #webdav
        file_server
}

authentification works as expected. Should this be the expected output, if you open it in chrome the site?

<D:multistatus xmlns:D="DAV:">
<D:response>
<D:href>/</D:href>
<D:propstat>
<D:prop>
<D:resourcetype>
<D:collection xmlns:D="DAV:"/>
</D:resourcetype>
<D:displayname/>
<D:getlastmodified>Thu, 17 Aug 2023 18:30:39 GMT</D:getlastmodified>
<D:supportedlock>
<D:lockentry xmlns:D="DAV:">
<D:lockscope>
<D:exclusive/>
</D:lockscope>
<D:locktype>
<D:write/>
</D:locktype>
</D:lockentry>
</D:supportedlock>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>

Because in chrome I get a response from the site ... Not sure is this is what I would expect due to no experience regarding webdav ...

Kind regards

wader commented 1 year ago

Yeap that looks like webdav-ish. I think you can do webdav request with curl by doing something like curl -H "Depth: 1" -X PROPFIND http://host/path. So if the webdav share is under some path like http://host/dav i think you need to use prefix /dav to get the webdav server know how to produce URL:s

Maybe it's worth trying with webdav client that is known to work first? think i've used macOS finder and kodi.

DanielOberlechner commented 1 year ago

I found a workaround with finder: https://webdav.danobe.dev:6180

with config:

{
        order webdav before file_server
}

webdav.danobe.dev:6180 {
        basicauth {
                user $2a$14$9SMz8Yufvqjm03TuaBvesecPC9/pnE11hQh3YpLUkMG8XCP2Sr4GG
        }
        webdav {
                root /webdav
        }
        file_server
}

will work in finder, but not in Rider. The difference is Rider uses dav:// and in finder it doesn't work with dav:// prefix but with the https:// prefix...

Anyone an idea what I do wrong here? why does it work with https as prefix? The problem in Rider is, I can't change the dav:// prefix to https:// because it inserts it automatically ...

Googleing the problem also had no answer for me.

Thank you @wader for your input with Finder, that was a good idea! :)

mholt commented 1 year ago

@DanielOberlechner I'm guessing the dav prefix doesn't use TLS? Whereas HTTPS is just webdav HTTP requests over TLS? Quick googling suggests Rider may not support WebDAV over TLS (but it does support FTP over TLS)...