代码之家  ›  专栏  ›  技术社区  ›  surajravi

nginx-webdav无法打开集合

  •  6
  • surajravi  · 技术社区  · 10 年前

    我已经在freebsd系统上使用以下配置参数构建了nginx:

    ./configure ... –with-http_dav_module

    现在这是我的配置文件:

    user www www;
    worker_processes  1;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        # reserve 1MB under the name 'proxied' to track uploads
        upload_progress proxied 1m;
    
        sendfile        on;
        #tcp_nopush     on;
        client_max_body_size 500m;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
        #upload_store /var/tmp/firmware;
        client_body_temp_path /var/tmp/firmware;
    
    
        server {
          server_name localhost;
          listen 8080;
    
          auth_basic "Restricted";
          auth_basic_user_file /root/.htpasswdfile;
    
          create_full_put_path on;
          client_max_body_size 50m;
          dav_access user:rw group:r all:r;
          dav_methods PUT DELETE MKCOL COPY MOVE;
          autoindex on;
          root /root;
    
          location / {
          }
        }
    }
    

    现在,接下来我要做的是通过发出 nginx -t 然后按如下方式进行优雅的重新加载: nginx -s reload .

    现在,当我将网络浏览器指向nginxip地址:8080时,我会得到文件和文件夹等的列表(我认为这是由于自动索引功能)。

    但问题是,当我尝试使用尸体测试webdav时,如下所示:

    cadaver http://nginx-ip-address:8080/

    它要求我输入授权凭据,然后在我输入后,它会给我以下错误:

    Could not open Collection: 405 Not Allowed

    下面是同时出现的nginx错误日志行:

    *125 no user/password was provided for basic authentication, client: 172.16.255.1, server: localhost, request: "OPTIONS / HTTP/1.1", host: "172.16.255.129:8080"

    当我尝试从web浏览器访问它时,用户名和密码都正常工作,那么这里发生了什么?

    1 回复  |  直到 10 年前
        1
  •  13
  •   surajravi    10 年前

    事实证明,内置nginx中的webdav模块已损坏,为了启用完整的webdav,我们需要添加以下外部第三方模块:nginx-dav ext模块。

    链接到其github: https://github.com/arut/nginx-dav-ext-module.git

    配置参数现在为:

    ./configure --with-http_dav_module --add-module=/path/to/the/above/module

    内置的一个仅提供 PUT DELETE MKCOL COPY MOVE dav方法。

    nginx-dav ext模块添加了以下附加的dav方法: PROPFIND OPTIONS

    您还需要编辑配置文件以添加以下行:

    dav_ext_methods PROPFIND OPTIONS;

    完成后,通过发出以下命令检查conf文件的语法是否完整: nginx -t

    然后软加载(优雅地)nginx: nginx -s reload

    瞧!现在,您应该能够使用deal或其他任何dav客户端程序进入目录。

    我不敢相信我解决了这个问题,这让我有一阵子发疯了!