Dataplicity Developer Hub

Dataplicity Documentation

Here you'll find announcements for new features and comprehensive guides to help you integrate Dataplicity into your Raspberry Pi projects.

Get Started    Announcements

Run WebDAV over Wormhole

Remotely share and access your files at <yourdevice> using WebDAV.

Using WebDAV, Dataplicity Wormhole makes it possible to remotely access files from your Raspberry Pi.

WebDAV succesfully working.

WebDAV succesfully working.


For the purposes of this guide, we'll assume that you have your Pi powered up, connected to the internet and have Dataplicity installed (see Getting started with Dataplicity). We'll also assume you know how to Host a website from your Pi.


WebDAV allows you to upload and download files using a web browser, WebDAV client, or by mapping a drive in your PC OS.

On the target device we will setup an 'Apache' web server, with its DAV module loaded.

Install Apache

sudo apt-get update
sudo apt-get install apache2

The Apache web server is now installed and running. This can be verified by going to your wormhole address. It will display apache web servers default page.

Apache web server succesfully installed and working.

Apache web server succesfully installed and working.

Configure WebDAV

There are three steps to set up WebDAV.

  1. Create a directory to share
  2. Configure and enable Apache to host WebDAV
  3. Secure WebDAV (put a password on it)

Create a directory to share

Create the WebDAV directory and change its ownership to the web service user "apache".

sudo mkdir /var/www/webdav

To create a few empty files inside that directory you can use 'touch'.

sudo touch /var/www/webdav/file-example1.empty
sudo touch /var/www/webdav/file-example2.empty
sudo touch /var/www/webdav/file-example3.empty

Check the files exist.

Verify that the directory and files were created successfully

Verify that the directory and files were created successfully

Finally, set the directory ownership such that all files are accessible to the web service user.

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

Configure and enable Apache to host WebDAV

First, enable the WebDAV module. This is done using the Apache management command 'a2enmod'.

sudo a2enmod dav
sudo a2enmod dav_fs

Edit the configuration file for the default Apache web site using your favourite text editor. In this example we are using 'nano'.

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

The file should initially contain something like this:

<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.

        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

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

Add the following lines before </VirtualHost> :

Alias /webdav /var/www/webdav

<Directory /var/www/webdav>

How it works

The "Alias" directive maps requests from http://your.server/webdav to the /var/www/webdav folder on your system.

The "Directory" directive tells Apache to enable WebDAV for the /var/www/webdav folder.

The final step is to restart the Apache web server so that changes can take effect.

sudo service apache2 restart

At this point, everything should be working. You should be able to access your WebDAV folder using your web browser at your wormhole URL with a "/webdav" suffix. Like so:

In this case, those three empty files we created earlier should now be visible.

WebDAV succesfully working.

WebDAV succesfully working.

Securing WebDAV

By default, WebDAV doesn't enable any authentication, so your Pi is sharing the WebDAV directory to anyone who wants to see it. This is probably not what you want, so we need to put a password on it.

Windows, Linux and Mac all support 'digest' authentication, and we will use this so the share is accessible directly in each OS even without a web browser.

There are two steps to enabling digest authentication in Apache:

  1. Generate a password file (known as a user digest) and add users
  2. Edit apache web server configuration file and include the digest file

Generate a password file

We will need to install the Apache web server support utilities.

sudo apt-get install apache2-utils

We start by generating the password file.

sudo htdigest -c /etc/apache2/users.password webdav pi

When this command is executed you will be asked to type in a password for the user that has just been created. For the purposes of this example we've entered "raspberry" as our password for the user "pi", but you will want to choose your own.

If you would like to add more users you use the same command but without "-c" option.

The -c option will recreate the digest

If you would like to add further users, remember to remove "-c" option. If you keep using "-c", you'll keep replacing your digest file with a new file, and you'll erase any previous users you've added.

We need to change ownership of that the digest file to ensure Apache can read it.

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

Edit the Apache web server configuration file

In your favourite editor, reopen the Apache server configuration file you were editing earlier.

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

Insert a few more lines between the "Directory" tags we added previously.

    <Directory /var/www/webdav>
        DAV On
        AuthType Digest
        AuthName "webdav"
        AuthUserFile /etc/apache2/users.password
        Require valid-user

How it works

The "AuthType" directive instructs Apache that for the /var/www/webdav directory, there should be authentication using the Digest scheme.

The "AuthName" directive is used to set the value for realm which is required by digest authentication. Realm is like a namespace. In case there are users with the same name, you can separate them based on their realm.

The "AuthUserFile" directive indicates where the password file is stored.

The "Require valid-user" directive will only allow users who authenticated themselves to acces WebDAV directory.

Finally, enable the Digest module and restart the server for the settings to take effect.

sudo a2enmod auth_digest
sudo service apache2 restart

When you refresh your WebDAV folder in your browser you should now be asked for login credentials.

WebDAV with user authentication

WebDAV with user authentication

Awesome :)

Run WebDAV over Wormhole

Remotely share and access your files at <yourdevice> using WebDAV.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.