WebDAV

From Bibliotheca Anonoma

WebDAV: easier, safer, faster, and more accessible alternative to FTP and SFTP, using an HTTP Server for speed and convenience.

You can choose either Apache or Nginx as the HTTP Server. Or you can use BarracudaDrive which has the whole WebDAV system packaged up.

BarracudaDrive (RaspberryPi Only)[edit]

BarracudaDrive is a complete personal cloud package that uses WebDAV. It has binaries for Windows, Mac OS X, and Raspberry Pi.

Apache[edit]

Since WebDAV runs on an HTTP server, the port is naturally Port 80 by default. If you are using WebDAV, should probably bind mount another folder to /var/www/webdav/ (or whatever it is named, see below for info).

Make sure you have Apache installed.

sudo apt-get update
sudo apt-get install apache2

You wiil need to setup a directory to store WebDAV, lets put it in /var/www/webdav. You also need to allow Apache to access the files.

sudo mkdir /var/www/webdav
sudo chown -R www-data:www-data /var/www/

Enable the WebDAV modules using a2enmod

sudo a2enmod dav
sudo a2enmod dav_fs

Open or create the config file at /etc/apache2/sites-available/000-default.conf

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

Type DavLockDB /var/www/DavLock on the first line to add the DavLockDB directive config.

Add Alias and Directory directives inbetween <VirtualHost> and </VirtualHost>.

Alias /webdav /var/www/webdav

<Directory /var/www/webdav>
    DAV On
</Directory>

Your file should now look like this:

DavLockDB /var/www/DavLock
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
 
        Alias /webdav /var/www/webdav

        <Directory /var/www/webdav>
            DAV On
        </Directory>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Now restart the server using sudo service apache2 restart.

Adding Authentication[edit]

To start, generate a file called users.password to store the passwords for users. But first, make sure to install apache utils

sudo apt-get install apache2-utils

Assuming that your username is antonizoon put in a password and make the password file.

sudo htdigest -c /etc/apache2/users.password webdav antonizoon
  • If you want to add more users, just remove the -c from the command above and replace the username to the user you are adding.

Give Apache access to the password file.

sudo chown www-data:www-data /etc/apache2/users.password

Edit the apache configuration

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

Add these lines between <Directory /var/www/webdav> and </Directory> without deleting DAV on

AuthType Digest
AuthName "webdav"
AuthUserFile /etc/apache2/users.password
Require valid-user

Now enable digest mode and restart apache

sudo a2enmod auth_digest
sudo service apache2 restart

You probably want to bind mount your hard drive or your downloads folder to the webdav folder, so check this out.

Nginx[edit]