WebDAV, the DAV stands for Distributed Authoring and Version. In its simplest form would be a folder that can be accessed from the web that has a username and password to keep the content locked. There are two versions basically, plain and SSL which is secure in that the data that flows in and out of the folder is encrypted as it moves through the web. In this post I am covering the simple non-SSL form for starters.
This post assumes that Apache is installed, if you need to install it do…
sudo apt-get install apache2
Then load the Apache modules for DAV…
sudo a2enmod dav
sudo a2enmod dav_fs
Create a folder for WebDAV
I created a directory at…
/srv/homes/webdav
…the command…
mkdir -p /srv/homes/webdav
…will allow the folders above webdav, such as homes be created if they do not exist.
Edit the Apache default file
The WebDAV folder access is simply controlled by the sites-available/default file. To edit it run…
sudo nano /etc/apache2/sites-available/default
Towards the bottom of the file right above the section that has the ScriptAlias for the /cgi-bin/ directory, I placed the following code…
Alias /webdav /srv/homes/webdav
<Location /webdav>
Options Indexes
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /etc/apache2/webdav.password
Require valid-user
</Location>
Adding the Password
Use the htpasswd command to add a password to a webdav.password file. it will prompt you for a password. The file will contain hashed passwords which are not readable.
sudo htpasswd -c /etc/apache2/webdav.password username
For an extra level of protection you can change ownership of the file to root with the group of www-data, so no regular users can access the file. Setting the permission to read-write for owner root and read only for the www-data group…
sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password
Access the Folder
With everything setup the folder will now appear at http://your-url-here.com/webdav, you can browse to it to test it out. You will be prompted for the user-name and password created earlier in the adding the password step.
Further Potential for WebDAV
- Setup multiple WebDAV folders.
- Put a web folder on expanded storage on a Raspberry Pi, such as use a bind mount to point to a USB stick plugged into the Pi for extra storage space.
- It is possible to set up WebDAV with SSL to secure it in a way that the data flowing in and out of the folder will be secured from prying eyes. With my non-SSL WebDAV folder, I don’t put anything up there that is critical or really private data.
- It is possible to use DAV for support of calendars across devices, something I will explore in the future.
- There is an app for the iPhone that I have tried that allows easy uploading and downloading to the WebDAV folder. It is easy to drop attachments from email and etc. to the folder for access on a PC.
Resources
https://www.digitalocean.com/community/tutorials/how-to-configure-webdav-access-with-apache-on-ubuntu-12-04
WebDAV Resources