我在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
.现在,当我将我的网络浏览器指向 nginx-ip-address:8080 时,我会得到我的文件和文件夹的列表等等(我认为这是由于自动索引功能)。
但问题是,当我尝试使用 cadaver 测试 webdav 时,如下所示:
cadaver http://nginx-ip-address:8080/
它要求我输入授权凭据,然后在我输入之后它给了我以下错误:
Could not open Collection: 405 Not Allowed
以下是同时出现的 nginx-error-log 行:
*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"
当我尝试从网络浏览器访问用户名和密码时,用户名和密码工作正常,那么这里发生了什么?
最佳答案
事实证明,nginx 内置的 webdav 模块已损坏,要启用完整的 webdav,我们需要添加以下外部 3rd 方模块:nginx-dav-ext-module。
链接到它的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-module 添加了以下额外的 dav 方法:PROPFIND OPTIONS
您还需要编辑配置文件以添加以下行:dav_ext_methods PROPFIND OPTIONS;
这样做后,通过发出以下命令检查 conf 文件的语法是否完整:nginx -t
然后软重新加载(优雅地)nginx:nginx -s reload
瞧!您现在应该能够使用 cadaver 或任何其他 dav 客户端程序进入目录。
我不敢相信我解决了这个问题,它让我发疯了一段时间!
关于nginx webdav 无法打开集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24666457/