How To Set Up WebDAV With Apache2 On Ubuntu 15.04 Server

Sponsored Link
Web Distributed Authoring and Versioning (WebDAV) is an extension of the Hypertext Transfer Protocol (HTTP) that facilitates collaboration between users in editing and managing documents and files stored on World Wide Web servers.

The WebDAV protocol makes the Web a readable and writable medium.It provides a framework for users to create, change and move documents on a server; typically a web server or web share. The most important features of the WebDAV protocol include the maintenance of properties about an author or modification date, namespace management, collections, and overwrite protection. Maintenance of properties includes such things as the creation, removal, and querying of file information. Namespace management deals with the ability to copy and move web pages within a server’s namespace. Collections deal with the creation, removal, and listing of various resources. Lastly, overwrite protection handles aspects related to locking of files.

Prerequisite

Ubuntu 15.04 server installation and we are going to use the server ip 192.168.56.101

Install apache2 server using the following command

sudo apt-get install apache2 apache2-utils

Install required modules using the following commands

sudo a2enmod dav

sudo a2enmod dav_fs

Restart Apache2 using the following command

sudo service apache2 restart

Apache2 Virtualhost Configuration

We will now create a default Apache vhost in the directory /var/www/webdav . For this purpose,we will modify the default Apache vhost configuration in /etc/apache2/sites-available/000-default.conf.

First, we create the directory /var/www/webdav and make the Apache user (www-data) the owner of that directory

sudo mkdir -p /var/www/webdav

sudo chown www-data /var/www/webdav

Now we need to edit the /etc/apache2/sites-available/000-default.conf file

sudo vi /etc/apache2/sites-available/000-default.conf

Add the following information

NameVirtualHost *
<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/webdav/
<Directory /var/www/webdav/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

</VirtualHost>

Restart Apache2 using the following command

sudo service apache2 restart

Configure The Virtual Host For WebDAV

Now we create the WebDAV password file /var/www/webdav/passwd.dav with the user andy

sudo htpasswd -c /var/www/webdav/passwd.dav andy

You will be asked to type in a password for the user andy.

Now we change the permissions of the /var/www/webdav/passwd.dav file so that only root and the members of the www-data group can access it:

sudo chown root:www-data /var/www/webdav/passwd.dav

sudo chmod 640 /var/www/webdav/passwd.dav

Now we modify our vhost in /etc/apache2/sites-available/000-default.conf and add the following lines

Alias /webdav /var/www/webdav

<Location /webdav>
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/webdav/passwd.dav
Require valid-user
</Location>

Restart Apache2 using the following command

sudo service apache2 restart

Testing WebDAV

We will now install cadaver, a command-line WebDAV client using the following command

sudo apt-get install cadaver

To test if WebDAV works, type the following command

cadaver http://192.168.56.101/webdav/

Output Looks as follows

root@ubuntu-VirtualBox:~# cadaver http://192.168.56.101/webdav/
Authentication required for webdav on server `192.168.56.101′:
Username: andy
Password:
dav:/webdav/>

Sponsored Link

You may also like...

2 Responses

  1. Bruce Ferrell says:

    Do NOT put the password file into the dav directory. It’s possible to protect, but in this demonstration, it’s NOT protected. I tend to put password files completely outside the tree accessible to web request and I add a files directive to prevent the password being accessed by web requests

    order deny,allow
    Deny from all
    # whitelist First IP Address
    # allow from xx.xxx.xx.xx

  2. asdf says:

    You probably shouldn’t put your password file in the DAV writable area.

Leave a Reply

Your email address will not be published. Required fields are marked *