Create WebDAV server

I installed OpenWRT on a Sagem router (from Orange, intended for a "copper" ADSL connection). Of course, the ADSL port does not work. I connected the Huawei LTE modem to the USB port, which is additionally equipped with an SD memory card slot. Everything works OK, I have an LTE/4-port Ethernet/WiFi router with an additional 32 GB memory, formatted as EXT4.
I would like to save on this SD card the measurement data measured by 7 IoT devices based on 8266. The only available method of sending data from these devices is POST data over HTTP from IoT to the router and specifically the SD card.
My question is. How do you run a WebDAV server on OpenWRT that allows you to save data sent via IoT devices to files?

I would start with looking for the relevant packages:[Description_wiki*~]=webdav

As far I know there is no small vebdav servers. You can try nginx with extwebdav module. But if you need only save then you can create a simple cgi bin script. Also you can use ubus over rpc and call file service.

lighttpd has a webdav support and I created an instruction
I tested on TL-WR1043ND with SSD and it works very fast.
UPD: Moved the instruction to wiki


i tried to follow the officiale guide
but unfortunatly i dont know how to ultimate the last step, i need a better UI that allows me to upload via the browser. THX

Generally WebDAV is used by a specialized clients like Windows Mount Network disk.
But if you really want to have an access directly from a browser then the simplest way would be this:
Create a file in /dav/index.html with the content:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href=""/>
<script src=""></script>

Then open http://YourSite/dav/ and you'll see a simple file manager.

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

Also please note that you must configure HTTPS if you are going to access your files from internet.

If you still have issues feel free to call me and share screen in telegram: stokito
As an author of the instruction I'm interested to make it as clear as possible

1 Like

My goal is to load the measured value from IoT devices using the ESP32 processor (based on the FW of the EasyESP project) to the file located on the SSD connected to the USB port of the router.
More specifically, add subsequent measurements to the existing file. The shell script on the router will create consecutive files, each one containing data from the same day.

EasyESP has the ability to define "Generic HTTP call" in which I can use a variable containing the value of the measurement performed. And it is with this "Generic HTTP call" I would like to write data to files on the disk connected to the router.
Is it possible?

The WebDAV supports PUT request to create a file so yes.
But for a simplicity and avoiding installing of Lighttpd and it's mod_dav you can just use a plain CGI script in shell. Here is a simple example
To read POST/PUT data have a look in internet.

If you are using OpenWrt then out of the box you have a basic messaging system called UBUS. So it will be better to create a ubus service and use JSON-RPC calls via http. But the RPC call have an additional header and relies on OpenWrt so for the simplest usage as you described the plain CGI script will work just great.

OK. Will try plain CGI shell script.

thank you very much, did it work, is there any chance of having a better interface?

The better Web UI for WebDAV is something that is not so easy to do. For example if you want to see photos thumbnails (miniatures) then this is not supported directly by the WebDAV.
If you really need a best possible UI with cloud features then the only option is to install NextCloud but it works much slower because is written in PHP.

See my comment on the topic

Hi there!
I'm doing everything like in the wiki article, but I'm stuck with this error:

/etc/init.d/lighttpd start
2023-08-10 23:34:22: (../src/mod_webdav.c.1331) sqlite3_open() '/var/lib/lighttpd//webdav.db': unable to open database file
2023-08-10 23:34:22: (../src/server.c.1913) Configuration of plugins failed. Going down.
lighttpd.conf validation failed

Unfortunately I don't find any solution yet. Any ideas?

chown -R root:www-data /etc/lighttpd/

solve my problem

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.