Setup Webdav using Caddy

2022-03-09 - setting up Caddy web server for Webdav

1. Prerequisites

In order to set up webdav you need to have Caddy installed. You can check how to do that in the beginning of the previous post.

2. Install Caddy Webdav module

Caddy Webdav requires installing a separate module. There are many ways to install module, from compiliing directly from source to installing a separate xcaddy tool to manage modules.

The easiest way however, is to add it directly from the caddy using his built-in add-package command.

sudo caddy add-package
sudo systemctl restart caddy

3. Configuring Caddy

Now you need to edit Caddy config, file to add Wedbav support.


# configure webdav module
    order webdav before file_server

# set up webdav for the host {
    root * /data/webdav
    basicauth {
        user1 hashed-password

This setup will configure webdav module to domain and use /data/webdav as a root directory.

It also secures access to file using basic authentication. Hashed password for the user1 can be generated using Caddy:

caddy hash-password

Just paste the output of the above command into the config file.

You can now access your files using webdav prtocol from anywhere.

Keywords: caddy webdav site hosting linux