A WebDAV server

WebDav is a HTTP extension which allows users to put files, create directories, just like you would do using a FTP server. Its major advantages on FTP are that it uses a unique TCP inbound communication channel and passes though web standard ports (it's still HTTP !), reducing problems for accessing from firewalled networks, and takes profit from web servers in general, such as authentication and the use of HTTPS secured communication channels.

A simple WebDav application is for instance the SyncPlaces Firefox extension, allowing you to share your bookmarks among different computers, using the WebDav server for storing the bookmarks files.

This tutorial supposes you have already installed the Apache server (for instance, by following the steps in this previous article), as well as HTTPS support (as described there).

WebDAV module activation

As root, issue the commands:

a2enmod dav_fs
/etc/init.d/apache2 restart

Creating a WebDAV secured directory

A simple way to proceed is to place the directory in a web/dav subdirectory of a local user's home page. This directory will be available from an alias subdirectory in your website, such as http://yoursite.com/dav/.

The directory will locally be located in the /home/user/www/dav directory. Of course, you will have to replace user with a real Unix user name on your system. The directory will be accessible from the internet using a username and a password of your choice.

As root

You will have to be sure your user has the www-data group rights. To add the specific group rights, issue the following command as root:

adduser user www-data

Of course, replace user with the actual Unix user name.

Setup the directory by adding the following lines in the VirtualHost section of the /etc/apache2/sites-available/default-ssl file:

Alias /dav/ "/home/user/www/dav/"
<Directory /home/user/www/dav/>
Order allow,deny
allow from all
Dav On
AuthType Basic
AuthName DAV
AuthUserFile /home/user/www/dav/.htpasswd
Require user webusername

For this last command, you may replace webusername with any user name you want. It does not need to be a valid Unix user.

As the concerned user

If your user just got the www-data group rights, you will have to log out and log in again.

Issue the commands:

mkdir -p $HOME/www/dav
chgrp www-data $HOME/www/dav
chmod g+ws $HOME/www/dav
htpasswd -c $HOME/www/dav/.htpasswd webusername

The webusername value must be the same as the one you previously set up for the Require User option in the default-ssl file. Enter the password from which your directory will be accessible from the internet.

As root again

Issue the command:

/etc/init.d/apache2 restart

And voilà !

PlacesSync setup

To setup the SyncPlaces Firefox extension, simply set the following server connection parameters:

  • Protocol: https
  • Host: The IP or domain name of your server
  • User and password: the webusername and password you set up with the htpasswd command

In the synchronization tab, ensure the file paths start with the /dav/ prefix (only the /dav/ directory is writable !).


1. On 13/07/2009, 08:40 by Arnaud

J'ai tout compris