WebDAV Share

WebDAV is an HTTP based file transfer protocol. It's integrated into Windows, GNOME, KDE and many programs for backups, file sharing and media players.

It's installed as a plugin for a web server. Unfortunately OpenWrt's uhttpd doesn't support it. If you have enough space you can install Lighttpd webserver and configure WebDAV share.

First of all if you already have the Lighttpd then update it and it's modules to avoid conflicts:

opkg update
opkg list-upgradable | cut -f 1 -d ' ' | grep lighttpd | xargs opkg upgrade

Assuming that USB drive is mounted to /mnt/disk/ folder.

mkdir -p /etc/lighttpd/conf.d /mnt/disk/dav /var/lib/lighttpd
chown http:www-data /mnt/disk/dav /var/lib/lighttpd
cat << "EOF" > /etc/lighttpd/conf.d/99-disk.conf
$HTTP["url"] =~ "^/dav($|/)" {
  server.document-root := "/mnt/disk/"
  auth.backend = "plain"
  auth.backend.plain.userfile = "/etc/lighttpd/webdav.shadow"
  auth.require = (
    "/dav/" => ("method" => "basic", "realm" => "disk", "require" => "valid-user")
  auth.cache = ("max-age" => "3600")
opkg update
opkg install lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-webdav

Now set a password:

echo "youruser:somesecret" > /etc/lighttpd/webdav.shadow

Note: your secret is not encoded and saved on router in clear text for a better performance. If a hacker get access to the file it can see your password. So don't put here a password that you are using anywhere else. Just generate a new one for example with the command:

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}; echo

And finally restart Lighttpd:

/etc/init.d/lighttpd restart

Open in a browser and you'll be prompted for credentials. After login you'll see a directory listing but this not yet a WebDAV, just an additional feature.

To connect to WebDAV see Accessing WebDAV Server.

A quick test can be done with a curl (replace the youruser):

curl -u youruser:pass -X PROPFIND -H 'Depth: 1'

You must see a 207 status code and XML response with directory listing.

See more details and examples WebDAV with curl

Please note that you must configure HTTPS if you are going to access your files from internet. You'll need to get a TLS certificate and configure lighttpd for HTTPS

As with usual HTTP you can see (GET) any file directly from a browser but you can't see a listing of files in a folder. That's because for a listing is used a PROPFIND method but not just GET. But you can install a browser extension or more advanced app.

But a better is to install the small and nice UI webdav-js. Just create a file in dav folder's root `/mnt/disk/dav/index.html`

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/dom111/webdav-js/assets/css/style-min.css"/>
<script src="https://cdn.jsdelivr.net/gh/dom111/webdav-js/src/webdav-min.js"></script>

Then open and you'll see a simple file manager. Internally it performs all webdav operations with AJAX e.g. sends a PROPFIND to list files.

The disadvantage of the method is that it's doesn't work for subfolders i.e. when you open then the index.html file wont be show. That's fine for 99% of usages.

You can also try an online apps that can connect directly to your WebDAV share to backup data. Some notable apps:

To allow online apps to connect with your WebDAV it need a CORS enabled. Here is an example https://gist.github.com/stokito/0a6274106d407ba6d9fb776e7773445d

Useful mobile apps that supports WebDAV sync:

  • Orgzly - Outliner for notes and to-do lists. Source code
  • CloudBeats - a music player. Proprietary.
  • EasySync - two way synchronization of images, videos, audio and downloads.
  • FolderSync - a backup and sync e.g. you can upload photos automatically. Proprietary.

You can advertise a WebDAV share with umdns. Then it will be seen in Network folder of a file manager in GNOME and KDE and can be discovered from a Kodi media player.

Install the umdns package with opkg install umdns and create a service description file:

  "lighttpd_webdav": {
    "service": "_webdav._tcp.local",
    "port": 80,
    "txt": [

The reload the umdns service with: ubus call umdns reload or service umdns reload.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2023/12/29 08:25
  • by stokito