WebDAV is an extension of the HTTP protocol that allows users to manage files on servers. There are many ways to manage files on a remote server. WebDAV has several benefits over other solutions such as FTP or Samba. In this article, we will go through how to configure your Apache server on Ubuntu 14.04 to allow native WebDAV access from Windows, Mac and Linux with authentication.
WebDAV offers several advantages.
Native integration on all major OSes(Windows, Mac, Linux). There is no need to install third party software to use WebDAV.
Supports partial transfers.
Depending on your situation, WebDAV may be the best solution for your needs.
There are many web servers around that supports WebDAV on Linux. However, Apache has the most compliant implementation of the WebDAV protocol out there. At the time in writing, WebDAV on Nginx and Lighttpd work but only partially.
Let us get Apache installed.
sudo apt-get update sudo apt-get install apache2
The Apache web server should be installed and running.
Setting up WebDAV
There are 3 steps to set up WebDAV. We designate a location, enable the necessary modules and configure it.
Step 1: Preparing the directories
We need to designate a folder for serving WebDAV. We are creating a new directory in
/var/www for that. You will also need to change the owner to
www-data(or whichever your Apache user is) in order to allow Apache to write to it.
sudo mkdir /var/www/webdav sudo chown www-data:www-data /var/www/
Step 2: Enabling modules
Next we enable the modules using a2enmod
sudo a2enmod dav sudo a2enmod dav_fs
The Apache modules are found under
/etc/apache2/modules-available. This creates a symbolic link from
We open the configuration file at
/etc/apache2/sites-available/000-default.conf using your favorite text editor. Add the following configuration.
DavLockDB /var/www/DavLock <VirtualHost *:80> Alias /webdav /var/www/webdav <Directory /var/www/webdav> DAV On </Directory> </VirtualHost>
The DavLockDB directive designates the name of the DAV Lock database. It should be a path to a file. The file does not need to be created. The directory should be writeable by the Apache server.
The Alias directive maps requests to
http://your.server/webdav to the
If you restart the Apache server, you will have a working WebDAV server without authentication.
Restart the Apache server like this
sudo service apache2 restart
The WebDAV server should be found at __http://
A WebDAV server without authentication is not secure. In this section we’ll add authentication to your WebDAV server. There are many authentication schemes available. We are only going to touch on the 2 simplest schemes: Basic and Digest authentication.
Which to use? Basic or Digest authentication?
Take a look at this table which illustrates the compatibility of the various authentication schemes on different operating systems. Note that if you are serving HTTPS, we are assuming your ssl cert is valid(not self-signed).
We’re going to cover the Digest authentication version since it works on all the operating systems without the need for a SSL cert.
Let us generate the file(called users.password) that stores the password for the users. In Digest authentication, there is the realm field which acts as a namespace for the users. We will use webdav as our realm. Our first user will be called alex.
To generate the digest file, we have to install the dependencies.
sudo apt-get install apache2-utils
After that, we generate the file.
sudo htdigest -c /etc/apache2/users.password webdav alex
There should be a password prompt for the password of alex.
For subsequent addition of users, you should remove the c flag. Another example adding a user called bob.
sudo htdigest /etc/apache2/users.password webdav bob
We also need to allow Apache to read it. So we change the owner of the file.
sudo chown www-data:www-data /etc/apache2/users.password
After the password file is created, we should make changes to the configuration at
DavLockDB /var/www/DavLock <VirtualHost *:80> Alias /webdav /var/www/webdav <Directory /var/www/webdav> DAV On AuthType Digest AuthName "webdav" AuthUserFile /etc/apache2/users.password Require valid-user </Directory> </VirtualHost>
The mod_authn module contains the definitions for the authentication directives. In essence, we instruct Apache that for the
/var/www/webdav directory, there should be authentication using the Digest scheme. The realm should be called webdav. Find the password from the file at /etc/apache2/users.password. Only valid users who authenticate themselves is able to acess that directory.
Finally, enable the digest module and restart the server for the settings to take effect.
sudo a2enmod auth_digest sudo service apache2 restart
We’ll demonstrate how to access your WebDAV server from the native file browsers of Mac, Windows and Linux(Ubuntu).
On Mac, open Finder. On the menu bar, find Go and select the option Connect to Server.
Enter the server address. It should be __http://
You will be prompted for a username and pssword. Enter them and press Connect.
Once you have connected, the directory should appear in Finder.
On Windows, open File Explorer. On the left sidebar, you should find the Network icon.
Right click on the Network icon. It should show the context menu with the option Map network drive. Click on that.
Enter the server address in the folder field. It should be __http://
You will be prompted for a username and password. Enter them and press OK.
Once you have connected, it should appear as a network drive on the left sidebar of your File Explorer.
We are using Ubuntu 14.04 as our Linux desktop operating system. On Ubuntu, open Files. THere is a Connect to Server option on the left sidebar. Click on that.
Enter the server address. It should be __dav://
You will be prompted for a username and password. Enter them and press Connect.
Once you have connected, the directory should appear under the Network listing.
In this article, we have gone through how to set up a WebDAV server using Apache on Ubuntu 14.04. We have also discussed how to configure Digest authentication to secure the server. Lastly, we have shown you how to connect to the WebDAV server from all 3 major operating systems using their native file browsers.