我在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来检查confiuration文件的语法,然后按如下方式进行正常的重新加载:nginx -s reload.

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

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

尸体http:// nginx-ip-address:8080 /

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

无法打开收藏:405不允许

以下是同时出现的nginx-error-log行:

* 125没有为基本认证提供用户/密码,客户端:172.16.255.1,服务器:localhost,请求:“OPTIONS / HTTP / 1.1”,主机:“172.16.255.129:8080”

当我尝试从网络浏览器访问它时,用户名和传递工作正常,那么这里发生了什么?

最佳答案
事实证明,内置在nginx中的webdav模块已损坏并启用完整的webdav,我们需要添加以下外部第三方模块:nginx-dav-ext-module.

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

configure参数现在是:

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

内置的只提供PUT DELETE MKCOL COPY MOVE dav方法.

nginx-dav-ext-module添加了以下额外的dav方法:PROPFIND OPTIONS

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

dav_ext_methods PROPFIND OPTIONS;

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

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

还有瞧!你现在应该可以使用尸体或任何其他dav客户端程序进入目录.

我无法相信我解决了这个问题,它让我疯了一会儿!

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。