WebDav configuration essense with Lighttpd on OpenWrt


To use webdav easily, you should install Lighttpd since onyl easy package to use webdav(or you can download source and compile the Nginx and other solutions).

execute this command first

opkg install lighttpd-mod-alias lighttpd-mod-webdav

In the '/etc/lighttpd/conf.d/99-myconf.conf'
you need put this kind of config(which is confirmed by myself)

    $HTTP["url"] =~ "^/webdav($|/)" {
        server.dir-listing = "enable"

        alias.url += ( "/webdav" => "/mnt/your path" ) #must be here inside
        server.document-root        = "/mnt/your path"

        webdav.activate = "enable"
        webdav.is-readonly = "enable"
        webdav.log-xml = "disable"
        webdav.sqlite-db-name = "/mnt/your path for cache/webdav.db"

Hi @Mitchell

Have you seen this error? how did you deal with this.

2018-11-27 19:12:49: (mod_webdav.c.229) can't open transaction: database is locked
2018-11-27 19:12:49: (server.c.1431) Configuration of plugins failed. Going down. 

I don't remember I had face the error.
But I have install and configure properly.

make 'nano /etc/lighttpd/conf.d/99-yourconfig.conf'('99' part is very important)
and put everything what you want in this file.
not others. I strongly recommend you never touch other auto generated configs.
(only touch you are FULLY understand).
then most of issue will not be shown.

And if keep occuring the issue,
'opkg remove lighttpd'
and reinstall.
and edit '99-xxxx.conf' again.

and stop and start your service. not restart.

And check that whether your webdav.db. file still being in use by another process.

I am trying to set up Webdav on the same model. MyBookLive, because i want to access from the outside world and share to other users.

My lighttpd.conf looks like this:

server.document-root        = "/www"
server.upload-dirs          = ( "/tmp" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "http"
server.groupname            = "www-data"
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
### Options that are useful but not always necessary:
#server.chroot               = "/"
#server.port                 = 81
#server.bind                 = "localhost"
#server.tag                  = "lighttpd"
#server.errorlog-use-syslog  = "enable"
#server.network-backend      = "writev"
### Use IPv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"
#dir-listing.encoding        = "utf-8"
#server.dir-listing          = "enable"
include "/etc/lighttpd/mime.conf"
include "/etc/lighttpd/conf.d/*.conf"

my 30-webdav looks like that:

**## See https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModWebDAV**
server.modules += ( "mod_webdav" )
$HTTP["url"] =~ "^/dav($|/)" {
  ## enable webdav for this location
  webdav.activate = "enable"
  **## By default the webdav url is writable.**
  **## Uncomment the following line if you want to make it readonly.**
  #webdav.is-readonly = "enable"
  **## Log the XML Request bodies for debugging**
  #webdav.log-xml = "disable"

webdav.sqlite-db-name = home_dir + "/webdav.db"

and finally my 99-webdav.conf like this:

$HTTP["url"] =~ "^/webdav($|/)" {
    server.dir-listing = "enable"

    alias.url += ( "/webdav" => "/mnt/sda3/DATA" ) #must be here inside
    server.document-root        = "/mnt/sda3/DATA"

    webdav.activate = "enable"
    webdav.is-readonly = "disable"
    webdav.log-xml = "enable"
    webdav.sqlite-db-name = "/tmp/log/lighttpd/webdav.db"

Does everything look good? Because i cannot connect to it via WEBdav when I try with an OSX MacBook Pro with High Sierra on it.
I will get the response There was a problem...: This file server will not allow any additional users to log on. Try to connect again later.

Any suggestions? what am I missing?

Well... my system has more complicated customization,
but I can highlight some of few part that my configuration.(most of them are same(or ignore-able) which I;m not mentioned below.
(you also need '20-auth' mod)

auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/htpasswd"

auth.require = ( "/" =>
"method" => "basic",
"realm" => "Login Require",
"require" => "user=guest|user=test1"

$HTTP["url"] =~ "^/webdav($|/)" {
server.dir-listing = "enable"

alias.url += ( "/webdav" => "/mnt/diskname/foldername" ) #must be here inside
server.document-root = "/mnt/diskname/foldername"

webdav.activate = "enable"
webdav.is-readonly = "enable"
webdav.log-xml = "disable"

Disable the log. the OpenWRT's log system on RAM which limit and small which you will lose the prior log in second if many user accessing it. And for performance.
And Disable write permission first. whether working.

Good luck.

And if the webdav properly setup,
your any internet web browser(chrome/IE, etc.) can be access the directories.
Test it before using WebDav player.

Hi Mitchell,

so what you posted was in which file? the lighttpd.conf or the 99-webdav.conf?
And how does the mod auth have to be activated? When i try to include it, it won't start the lighttpd..
And how does the /etc/htpasswd look like?

If you could post all separate files here (changed usernmaes and passwords of course.. that would be great..

Here you go.

  • Regarding location of the configuration snippet, it doesn't matter where they are, but in my case, in the 99-mitchell.conf.

  • Have no idea whether right for you, but do this.

opkg update && opkg install lighttpd lighttpd-mod-cgi luci-mod-admin-full libiwinfo lighttpd-mod-accesslog lighttpd-mod-setenv luci-theme-openwrt lighttpd-mod-proxy lighttpd-mod-access lighttpd-mod-expire lighttpd-mod-evasive lighttpd-mod-redirect lighttpd-mod-rewrite lighttpd-mod-proxy lighttpd-mod-auth lighttpd-mod-authn_file lighttpd-mod-alias lighttpd-mod-webdav php7 php7-cgi php7-fastcgi php7-mod-json lighttpd-mod-cgi

  • Regarding htpasswd, you should study the detail since not that simple by seeing human eyes. Google it.

  • For the debugging, open by chrome or any of web browser and check the log file '/var/log/lighttpd/error.log' which indicated by the configuration.

it is weird. the update and install went smooth. i was able to restart the deamon lighttpd.
But as soon as i make the changes according to your listing

auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/htpasswd"

auth.require = ( "/" =>
"method" => "basic",
"realm" => "Login Require",
"require" => "user=guest|user=test1"

it gives me this when trying to restart the lighttpd with stop and then start again...

root@OpenWrt:/# /etc/init.d/lighttpd start
validation failed

It...was very familiar error. I do not remember detail. It might the webdav cache path issue...

do the command :

/usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf

and check the log. and fix it.

I created an instruction https://gist.github.com/stokito/5db2aa2cc184717d45600889d8115100

But it doesn't fully works. Maybe you'll have a luck