Skip to content

dav-ext: NGINX WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK support

Debian/Ubuntu installation

These docs apply to the APT package nginx-module-dav-ext provided by the GetPageSpeed Extras repository.

  1. Configure the APT repository as described in APT repository setup.
  2. Install the module:
sudo apt-get update
sudo apt-get install nginx-module-dav-ext
Show suites and architectures
| Distro   | Suite             | Component   | Architectures   |
|----------|-------------------|-------------|-----------------|
| debian   | bookworm          | main        | amd64, arm64    |
| debian   | bookworm-mainline | main        | amd64, arm64    |
| debian   | trixie            | main        | amd64, arm64    |
| debian   | trixie-mainline   | main        | amd64, arm64    |
| ubuntu   | focal             | main        | amd64, arm64    |
| ubuntu   | focal-mainline    | main        | amd64, arm64    |
| ubuntu   | jammy             | main        | amd64, arm64    |
| ubuntu   | jammy-mainline    | main        | amd64, arm64    |
| ubuntu   | noble             | main        | amd64, arm64    |
| ubuntu   | noble-mainline    | main        | amd64, arm64    |

nginx WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK support.

About

The standard ngx_http_dav_module provides partial WebDAV implementation and only supports GET,HEAD,PUT,DELETE,MKCOL,COPY,MOVE methods.

For full WebDAV support in nginx you need to enable the standard ngx_http_dav_module as well as this module for the missing methods.

Testing

The module tests require standard nginx-tests and Perl HTTP::DAV library.

$ export PERL5LIB=/path/to/nginx-tests/lib
$ export TEST_NGINX_BINARY=/path/to/nginx
$ prove t

Locking

  • Only the exclusive write locks are supported, which is the only type of locks described in the WebDAV specification.
  • All currently held locks are kept in a list. Checking if an object is constrained by a lock requires O(n) operations. A huge number of simultaneously held locks may degrade performance. Thus it is not recommended to have a large lock timeout which would increase the number of locks.

Directives

dav_ext_methods

Syntax: dav_ext_methods [PROPFIND] [OPTIONS] [LOCK] [UNLOCK]
Context: http, server, location

Enables support for the specified WebDAV methods in the current scope.

dav_ext_lock_zone

Syntax: dav_ext_lock_zone zone=NAME:SIZE [timeout=TIMEOUT]
Context: http

Defines a shared zone for WebDAV locks with specified NAME and SIZE. Also, defines a lock expiration TIMEOUT. Default lock timeout value is 1 minute.

dav_ext_lock

Syntax: dav_ext_lock zone=NAME
Context: http, server, location

Enables WebDAV locking in the specified scope. Locks are stored in the shared zone specified by NAME. This zone must be defined with the dav_ext_lock_zone directive.

Note that even though this directive enables locking capabilities in the current scope, HTTP methods LOCK and UNLOCK should also be explicitly specified in the dav_ext_methods.

Example 1

Simple lockless example:

location / {
    root /data/www;

    dav_methods PUT DELETE MKCOL COPY MOVE;
    dav_ext_methods PROPFIND OPTIONS;
}

Example 2

WebDAV with locking:

http {
    dav_ext_lock_zone zone=foo:10m;

    ...

    server {
        ...

        location / {
            root /data/www;

            dav_methods PUT DELETE MKCOL COPY MOVE;
            dav_ext_methods PROPFIND OPTIONS LOCK UNLOCK;
            dav_ext_lock zone=foo;
        }
    }
}

Example 3

WebDAV with locking which works with MacOS client:

http {
    dav_ext_lock_zone zone=foo:10m;

    ...

    server {
        ...

        location / {
            root /data/www;

            # enable creating directories without trailing slash
            set $x $uri$request_method;
            if ($x ~ [^/]MKCOL$) {
                rewrite ^(.*)$ $1/;
            }

            dav_methods PUT DELETE MKCOL COPY MOVE;
            dav_ext_methods PROPFIND OPTIONS LOCK UNLOCK;
            dav_ext_lock zone=foo;
        }
    }
}