WebDAV

WebDAV (Web Distributed Authoring and Versioning) is an extension of HTTP/1.1 and therefore can be considered to be a protocol. It contains a set of concepts and accompanying extension methods to allow read and write across the HTTP/1.1 protocol. Instead of using NFS or SMB, WebDAV offers file transfers via HTTP.

The goal of this article is to setup a simple WebDAV configuration using a web server.

Server

Apache

Install the Apache HTTP Server.

Uncomment the modules for DAV:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so

Add the following line to /etc/httpd/conf/httpd.conf:

DAVLockDB /home/httpd/DAV/DAVLock

Make sure you add it outside of any other directives, for instance right under the DocumentRoot definition.

Next, add the following (also outside of any directives):

Alias /dav "/home/httpd/html/dav"

<Directory "/home/httpd/html/dav">
  DAV On
  AllowOverride None
  Options Indexes FollowSymLinks
  Require all granted
</Directory>

Create the directory:

# mkdir -p /home/httpd/DAV

Check the permissions of DavLockDB's directory and ensure it is writable by the webserver user http:

# chown -R http:http /home/httpd/DAV
# mkdir -p /home/httpd/html/dav
# chown -R http:http /home/httpd/html/dav

nginx

Install nginx-mainline (the mainline variant of nginx) and nginx-mainline-mod-dav-extAUR.

At the top of your and outside any blocks, add:

Add a new for WebDAV to your block, for example:

The above example requires the directories /srv/http/dav and /srv/client-temp to exist.

You may want to use bind mounts to make other directories accessible via WebDAV.

rclone

Install the package. It supports exporting a remote or local directory using webdav.

To serve the contents of with no authentication:

$ rclone serve webdav /srv/http

Client

Cadaver

Install the package.

After installation, test the WebDAV server:

$ cadaver http://localhost/dav
dav:/dav/> mkcol test
Creating `test': succeeded.
dav:/dav/> ls
Listing collection `/dav/': succeeded.
Coll: test

Dolphin

To create a permanent WebDAV folder in Dolphin select Network in the remotes section of the places sidebar, then press the Add Network Folder button. The network folder wizard will appear. Select WebFolder (webdav), and fill in the subsequent form.

Alternately just click the path bar and then enter the url with webdav:// protocol specifier.

Nautilus

In Nautilus just choose "connect to server" and enter the address with or protocol specified:

dav://127.0.0.1/dav

rclone

is a command line tool that lets you sync to/from, or mount (with many caching options), remote file systems including WebDAV.

Thunar

In Thunar just press and enter the address with dav or davs protocol specified:

davs://webdav.yandex.ru

Authentication

There are numerous different protocols you can use:

  • plain
  • digest
  • others

Apache

Using (remove the -c option if the file exists):

# htdigest -c /etc/httpd/conf/passwd WebDAV username

Using plain htpasswd(1) (remove the -c option if the file exists):

# htpasswd -c /etc/httpd/conf/passwd username

Next, must be edited to enable authentication. One method would be to require the user for everything:

If you want to permit everybody to read, you could use this in your httpd.conf

Do not forget to restart after making changes.

Troubleshooting

Some file explorers cannot edit directories in nginx WebDAV

nginx WebDAV requires a directory path ends with a slash (), but some file explorers does not append a at the end of the path.

This can be worked-around, by either removing the corresponding checking code and recompile it, or by appending the following code in a nginx block to add at the end of a request, if needed:

# The configuration was based on: https://nworm.icu/post/nginx-webdav-dolphin-deken/
# if the request method is MKCOL or is to a directory, add / at the end of the request if it was missing 
if ($request_method = MKCOL) {
    rewrite ^(.*[^/])$ $1/ break; 
}
if (-d $request_filename) { 
    rewrite ^(.*[^/])$ $1/ break; 
}

# if the request method is copy or move a directory, add / at the end of the request if it was missing
set $is_copy_or_move 0;
set $is_dir 0;
if (-d $request_filename) { 
    set $is_dir 1; 
}
if ($request_method = COPY) {
    set $is_copy_or_move 1;
}
if ($request_method = MOVE) {
    set $is_copy_or_move 1;
}
set $is_rewrite "${is_dir}${is_copy_or_move}";
if ($is_rewrite = 11) {
    rewrite ^(.*[^/])$ $1/ break;
}
gollark: Freenom require you to renew your domain 2 weeks before it expires, lest they take it away and charge money.
gollark: They really should use potatOS's *good* UUID generator.
gollark: Also, anyone want a black-market potatOS update manifest?
gollark: We have one? Neat.
gollark: Steal.
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.