arut/nginx-dav-ext-module

GitHub: arut/nginx-dav-ext-module

为 nginx 补充标准 WebDAV 模块缺失的 PROPFIND、OPTIONS、LOCK、UNLOCK 方法,实现完整的 WebDAV 协议支持。

Stars: 508 | Forks: 126

## nginx-dav-ext-module nginx_ WebDAV_ PROPFIND,OPTIONS,LOCK,UNLOCK 支持。 .. contents:: # 关于 标准的 ngx_http_dav_module_ 提供了部分的 WebDAV_ 实现,并且 仅支持 GET,HEAD,PUT,DELETE,MKCOL,COPY,MOVE 方法。 要在 nginx_ 中获得完整的 WebDAV_ 支持,你需要启用标准的 ngx_http_dav_module_ 以及此模块以补充缺失的方法。 # 构建 使用此模块构建 nginx_: .. code-block:: bash ``` # static module $ ./configure --with-http_dav_module --add-module=/path/to/nginx-dav-ext-module # dynamic module $ ./configure --with-http_dav_module --add-dynamic-module=/path/to/nginx-dav-ext-module ``` 如果在编译 nginx_ 时使用了此模块但未包含 ngx_http_dav_module_,将会 导致编译错误。 # 要求 - nginx_ 版本 >= 1.13.4 - ``libxml2`` + ``libxslt`` ``libxslt`` 库在技术上是多余的,之所以需要它,仅仅是因为 nginx_ 在 xslt 模块中支持这种组合。 使用 nginx 内置的机制来链接第三方库 会带来一定的兼容性好处。 然而,这种冗余可以在 ``config`` 文件中轻松消除。 # 测试 此模块的测试需要标准的 nginx-tests_ 和 Perl ``HTTP::DAV`` 库。 .. code-block:: bash ``` $ export PERL5LIB=/path/to/nginx-tests/lib $ export TEST_NGINX_BINARY=/path/to/nginx $ prove t ``` # 锁定 - 仅支持独占写锁,这是 WebDAV_ 规范中描述的唯一锁类型。 - 所有当前持有的锁都保存在一个列表中。 检查对象是否受锁限制需要 O(n) 操作。 大量同时持有的锁可能会降低性能。 因此,不建议设置过大的锁定超时时间,因为这会增加 锁的数量。 # 指令 ## dav_ext_methods ========== ==== *语法:* ``dav_ext_methods [PROPFIND] [OPTIONS] [LOCK] [UNLOCK]`` *上下文:* http, server, location ========== ==== 在当前作用域内启用对指定 WebDAV 方法的支持。 ## dav_ext_lock_zone ========== ==== *语法:* ``dav_ext_lock_zone zone=NAME:SIZE [timeout=TIMEOUT]`` *上下文:* http ========== ==== 定义具有指定 NAME 和 SIZE 的 WebDAV 锁共享内存 zone。 同时定义锁过期的 TIMEOUT。 默认的锁定超时时间为 1 分钟。 ## dav_ext_lock ========== ==== *语法:* ``dav_ext_lock zone=NAME`` *上下文:* http, server, location ========== ==== 在指定的作用域内启用 WebDAV 锁定。 锁存储在由 NAME 指定的共享内存 zone 中。 此 zone 必须使用 ``dav_ext_lock_zone`` 指令进行定义。 请注意,即使此指令在当前作用域内启用了锁定功能,HTTP 方法 LOCK 和 UNLOCK 也必须在 ``dav_ext_methods`` 中显式指定。 # 示例 1 简单的无锁示例: ``` location / { root /data/www; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; } ``` # 示例 2 带锁定的 WebDAV: ``` 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; } } } ``` # 示例 3 适用于 MacOS 客户端的带锁定 WebDAV: ``` 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; } } } ``` .. _ngx_http_dav_module: http://nginx.org/en/docs/http/ngx_http_dav_module.html .. _nginx-tests: http://hg.nginx.org/nginx-tests .. _nginx: http://nginx.org .. _WebDAV: https://tools.ietf.org/html/rfc4918 .. _`RFC4918 If Header`: https://tools.ietf.org/html/rfc4918#section-10.4
标签:Nginx, WebDAV, 客户端加密, 服务器扩展, 网络服务