修复nginx的WebDav创建文件夹,重命名文件的问题

最近对webdav兴趣颇为浓厚,正好nginx也支持webdav

总的来说搭建简单,效率极高

但问题也有的哈!比如不支持创建文件夹、重命名、移动文件。

一切都是“/“引发的血案!解决方法多种,但我这里取其一记录,以备不时之需。

只需在

location / {

……………………………………

if ($request_method = MKCOL) { rewrite ^(.*[^/])$ $1/ break; }  #解决webdav不能创建文件夹问题       
set $dest $http_destination;                                           
            if (-d $request_filename) {#解决webdav不能重命名问题                                                                                               
                rewrite ^(.*[^/])$ $1/;                                                                                               
                set $dest $dest/;                                                                                                     
            }                                                                                                                         
if ($request_method ~ (MOVE|COPY)) {#解决webdav不能复制、移动文件问题                                                                                                  
                more_set_input_headers 'Destination: $dest';                                                                          
            }                                                                                                                         
if ($request_method = PROPPATCH) {#解决webdav在Windows下面无法上传文件问题                                                                                                    
        add_header      Content-Type 'text/xml';                                                                                      
        return          207 '<?xml version="1.0"?><a:multistatus xmlns:a="DAV:"><a:response><a:propstat><a:status>HTTP/1.1 200 OK</a:s
}

……………………………………

}

image.png


内容版权声明:除非注明,否则皆为本站原创文章。

评论