1 Star 0 Fork 0

梦游到此处/nginx-dav-ext-module

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-2-Clause

nginx-dav-ext-module

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.

Build

Building nginx with the module:

# 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

Trying to compile nginx with this module but without ngx_http_dav_module will result in compilation error.

Requirements

  • nginx version >= 1.13.4
  • libxml2 + libxslt

The libxslt library is technically redundant and is only required since this combination is supported by nginx for the xslt module. Using builtin nginx mechanisms for linking against third-party libraries brings certain compatibility benefits. However this redundancy can be easily eliminated in the config file.

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;
        }
    }
}
Copyright (C) 2012-2018 Roman Arutyunyan All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

nginx WebDAV PROPFIND,OPTIONS,LOCK,UNLOCK support 展开 收起
C 等 2 种语言
BSD-2-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lazystars/nginx-dav-ext-module.git
[email protected]:lazystars/nginx-dav-ext-module.git
lazystars
nginx-dav-ext-module
nginx-dav-ext-module
master

搜索帮助