ngx_http_dav_module

File management over WebDAV with PUT, DELETE, MKCOL, COPY and MOVE

compiled inBSD-2-Clausesource docs

Overview

ngx_http_dav_module is intended for file management automation via the WebDAV protocol. It processes the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE against files under the location's root.

A file uploaded with PUT is first written to a temporary file and then renamed, so the docs recommend keeping client_body_temp_path on the same file system as the destination to avoid a cross-device copy; the "Date" request header can set the modification time. The module does not implement PROPFIND, OPTIONS or LOCK, so clients that require additional WebDAV methods will not work with it alone. The third-party dav-ext module at /modules/dav-ext/ adds the missing methods.

It is an official nginx module and is not built by default upstream, so it needs the --with-http_dav_module configure parameter. Combined with limit_except it is a common way to accept uploads from scripts or backup tools into a directory that nginx also serves.

Key directives

dav_methodsAllows the listed methods from PUT, DELETE, MKCOL, COPY and MOVE; default off denies all of them.
dav_accessSets permissions for newly created files and directories as user:, group: and all: entries, default user:rw.
create_full_put_pathLets PUT create all missing intermediate directories instead of only files in existing ones, default off.
min_delete_depthAllows DELETE only when the request path has at least this many elements, default 0.

Example

nginx.conf
location /uploads/ { root /data/www; client_body_temp_path /data/client_temp; dav_methods PUT DELETE MKCOL COPY MOVE; create_full_put_path on; dav_access group:rw all:r; min_delete_depth 2; # only the internal network may modify files limit_except GET { allow 192.168.1.0/24; deny all; } }

Availability

Compiled into every n.wtf nginx binary. Install nginx-extras and the directives above work out of the box, no load_module line needed.