1. Home
  2. Docker
  3. Run your own WebDAV server with Docker

Run your own WebDAV server with Docker

WebDAV is a neat technology that lets you manage and share files on a remote server. 5 minutes is all it takes to get up and running.

Sounds like FTP doesn’t it! WebDAV is similar but works over HTTP/HTTPS and has a few advantages: more flexible authentication and security, and better performance in many situations.

 Things you’ll need

A server — if you’ve already got one skip down to Install Docker section. To create a cloud server, follow the instructions below.

Create a Cloud Server

  1. Login to the Bytemark Panel.
  2. Add a Cloud Server with these settings:
    • Name: Give your server a name (eg, “webdav”)
    • Group: Leave as “default”
    • Resources: 1 Core, 1GiB Memory
    • Operating System: Debian 9
    • Discs: 25GiB SSD storage
    • Backup Schedule: Leave enabled (recommended)
  3. Your Cloud Server will be ready in a couple of minutes.
  4. The Panel will tell you the root password for your server. Save it!
  5. Click on the Console button next to your Cloud Server. You’ll know installation has finished when you see a login prompt. You can login with username root.

Install Docker

Login to your Debian 9 server and run these commands as root user:

apt-get update
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian `lsb_release -cs` stable"
apt-get update
apt-get install -y docker-ce
DEBIAN_FRONTEND=noninteractive apt-get install -y unattended-upgrades

Now you should have docker-ce installed, and security upgrades will be applied automatically overnight.

Run a WebDAV container

We maintain an easily configurable bytemark/webdav image, which runs Apache as a WebDAV server. We’re going use that here.

We don’t want our WebDAV documents to get lost if Docker restarts, so we need some persistent storage. One way to do that is to create a directory on the server called /srv/dav and bind mount that into the container.

You’ve got two choices here of what command to run, depending on whether you want HTTP or HTTPS.

Run these commands to run WebDAV on HTTP:

mkdir /srv/dav
docker run --restart always -v /srv/dav:/var/lib/dav \
    -e AUTH_TYPE=Digest -e USERNAME=alice -e PASSWORD=secret1234 \
    --publish 80:80 --name webdav \
    -e LOCATION=/webdav -d bytemark/webdav

Run these commands to run WebDAV on HTTPS with a self-signed certificate:

mkdir /srv/dav
docker run --restart always -v /srv/dav:/var/lib/dav \
    -e AUTH_TYPE=Basic -e USERNAME=alice -e PASSWORD=secret1234 \
    --publish 443:443 -e SSL_CERT=selfsigned --name webdav \
    -e LOCATION=/webdav -d bytemark/webdav

If you want to have a proper Let’s Encrypt certificate, see our more in-depth guide on WebDAV.

Connect to WebDAV

You can now connect to your WebDAV server to start uploading files!

(NB: The -e LOCATION=/webdav option we used above means WebDAV is available at the URL path http://example.com/webdav but you can change that to anything else you want.)

Mac OS Finder

  1. Click Go.
  2. Click Connect to Server.
  3. In the Server Address field, enter http://name.of.server.uk0.bigv.io/webdav
  4. Click Connect.

GNOME Files

  1. Press Ctrl-L.
  2. Enter dav://alice@name.of.server.uk0.bigv.io/webdav

There are some Linux command-line tools that you can use too, like cadaver.

Tweak your WebDAV server

We’ll cover some common examples below, but you can also visit https://hub.docker.com/r/bytemark/webdav/ for more information.

Anonymous access

By default, access to your files is forbidden without a login.

You might want to give read-only access to people without a login. To do that, stop your container (docker stop webdav) and run it again with this option: -e ANONYMOUS_METHODS=GET,POST,OPTIONS,PROPFIND

Multiple login users

If you want to have several different logins for different people, you can bind mount your own authentication file to /user.passwd and the container will use that instead. (This will overwrite any USERNAME and PASSWORD you specify.)

Run the commands below to create an authentication file on your server and add some logins. It will prompt you to enter some passwords.

touch /root/user.passwd
apt-get install -y apache2-utils
htdigest /root/user.passwd WebDAV alice
htdigest /root/user.passwd WebDAV bob

Stop your container (docker stop webdav) and run it again with -v /root/user.passwd:/user.passwd

Secure WebDAV with SSL and Let’s Encrypt

The instructions above covered how to run WebDAV over HTTPS with a self-signed certificate, which is sometimes enough.

However, you might want to have a proper SSL certificate. We recommend running a reverse proxy (eg, Traefik) to handle that, which we cover in our more in-depth guide on WebDAV.

Updated on February 20, 2019

Was this article helpful?

Related Articles

Have you tried Kubernetes?
Kubernetes (K8s) is helping enterprises to ship faster & scale their business. Sounds good? Let us build a K8s solution for your needs.
Register your interest