ServersUse Linux and WebDAV to Facilitate Online Collaboration

Use Linux and WebDAV to Facilitate Online Collaboration

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

The WebDAV protocol enables users to store and share files via HTTP. This
is particularly valuable in cases where HTTP is usually read-only, as WebDAV
allows writing as well. In addition to accessing documents, users can (with
suitable permissions) edit and
re-upload them. Think of it as a networked file-system run over http:
or as a way of supporting long-distance collaboration on files. The protocol
supports locking and versioning information, so once you’ve accessed the
WebDAV folder, you can edit files without risking overwriting
other people’s edits. These days, there are more and more ways available to
undertake online collaboration, but WebDAV remains a useful and
straightforward way to share files, especially as it’s supported by plenty of
software at both server and client end.

There are many options for online collaboration, but WebDAV remains a useful and straightforward way to share files. Software support at both the server and client ends sweetens the deal further.

Unlike FTP, HTTP provides strong authentication and encryption, as well as
caching and proxy support — and because WebDAV works over HTTP, WebDAV gets all of that for free. SSH would be another option, but
SSH is a bit more limited in terms of moving files around, and it has nowhere near the quality of client support and tools available.

WebDAV and Apache2

It’s straightforward to get an Apache server to serve up a
WebDAV folder. The Apache module you want is mod_dav. To enable
this on a Debian or Ubuntu system, just type:

a2enmod dav
a2enmod dav_fs
/etc/init.d/apache2 restart

mod_dav provides the server with the WebDAV functionality (i.e., it
implements the relevant HTTP protocol extensions), and mod_dav_fs
supports it, allowing access to resources in the server’s filesystem. Additional
detailed information on the dav and dav_fs
modules is available on the Apache web page.

You’ll also need to set up specific folders to access via WebDAV. Here’s
an example:

Dav On

Order Allow,Deny
Allow from all

AuthType Digest
AuthName WebDAV-Realm

AuthUserFile "/usr/var/webdav.passwd"

require user juliet

The most important line here is Dav On, which turns this
directory into a WebDAV one. The rest is about securing access to the
directory. It’s important to make sure you have authentication set up
before you enable WebDAV on any directories, or you’ll have a big security
hole. The config here uses MD5 Digest authentication (recommended over
htaccess for security), and would limit all access to the named user. You
could also use just require valid-user; or you can make your setup as
complicated as MD5 Digest allows.

To allow writing to (as well as reading from) your directory,
you’ll need to change the permissions on that directory appropriately. In
particular, the Apache user must be able to write to the directory.
Again, note the security issues here! Hence, it’s a good idea to keep your WebDAV
directory reasonably separate from the rest of your website files.

To set WebDAV up manually, you’ll need the following somewhere in
your Apache conf file:

LoadModule dav_module /usr/lib/apache2/modules/
LoadModule dav_fs_module /usr/lib/apache2/modules/

Then restart Apache, and set up the directory you want to use as above.

Client-Side DAV

While DAV is usually provided via a web server, web browsers aren’t a great
way to access it — at the most, you’ll get a directory listing (if
you’ve enabled that in your Apache setup) and read or download files, but not
edit or upload them.

If you want graphical access, the Nautilus and Konqueror file-browsers both
have built-in WebDAV support. Open the folder with
dav:// (you’ll be challenged for your
username and password), and you should be able to move files back and forth
from your local desktop, and edit them in place. If you have problems, check
the file/directory permissions server-side.

Another possible client for WebDAV is cadaver, a command-line
client that works rather like an FTP client. To make a connection, type:


You’ll be challenged for a username and password, then given a command-line
prompt in the specified folder. You can then use get filename and
put filename (or mget and mput) to grab or to
upload files. cadaver also allows you to edit the metadata on files, which Nautilus and Konqueror don’t.

Another option is to use fusedav (available as a package for
Debian or Ubuntu) to access WebDAV directories as part of your normal filesystem. You’ll need to add your user to the fuse usergroup
with adduser username fuse. Be sure to log out and in again so it takes
effect. Then use:

fusedav localfolder

to open the remote directory and mount it as localfolder. Note that
this directory must already exist. I had problems getting this to work,
but other people seem to be using it fine.

More Fun With WebDAV

mod_dav_fs, as used above, provides a back end that allows you to
use the server directory system to provide WebDAV files. There are also other
back end providers available — for example, you can use mod_dav_svn
to serve a Subversion repository via Apache. If you do this, you’ll need to
load the mod_dav_lock module as well (mod_dav_fs doesn’t
need this locking module as it does its own locking). As WebDAV is an open
protocol, there’s also scope to do other things with it yourself if you have
particular requirements. It’s a useful technology to have in your stable of
file-sharing options.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of “Linux System Administration Recipes: A Problem-Solution Approach” (Apress, 2009).

Follow ServerWatch on Twitter

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories