【介绍】
WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序可直接对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制。
【安装】
可以通过在编译时加入“–with-http_dav_module”以启用对WebDav协议的支持,但要让功能完整,支持客户端的操作,还要引入另一个模块:ngx-dav-ext-module。
nginx官方文档:“WebDAV clients that require additional WebDAV methods to operate will not work with this module.”
下载ngx-dav-ext-module:
cd /root/nginx-1.19.5 && wget https://github.com/arut/nginx-dav-ext-module/archive/master.zip && unzip master.zip
重新编译nginx:
参考:https://amon.org/nginx
参考:https://github.com/arut/nginx-dav-ext-module
cd /root/nginx-1.19.5 && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_v2_module --with-openssl=./openssl-1.1.1c --add-module=./ngx_cache_purge-2.3 --add-dynamic-module=./headers-more-nginx-module --add-dynamic-module=./ModSecurity-nginx --with-http_dav_module --add-dynamic-module=./nginx-dav-ext-module-master make && make install
【配置】
添加动态模块:
编辑:/usr/local/nginx/conf/nginx.conf ,添加:
load_module modules/ngx_http_dav_ext_module.so;
添加网站及目录:
编辑:/usr/local/nginx/conf/servers/webdav.com.conf
server { listen 80; listen 443 ssl http2; server_name webdav.com www.webdav.com; client_max_body_size 20M; ssl_certificate /etc/letsencrypt/live/webdav.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/webdav.com/privkey.pem; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; location / { autoindex on; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; create_full_put_path on; root /usr/local/nginx/html/webdav.com/; include /usr/local/nginx/conf/rewrite/webdav.com.conf; dav_access user:rw group:rw all:r; auth_basic "Authorized Users Only"; auth_basic_user_file /usr/local/nginx/conf/htpasswd/webdav.com.conf; } }
添加用户:
编辑:/usr/local/nginx/conf/htpasswd/webdav.com.conf
Admin:$1$5h/pBpa8$SIAAfaJaOHQqZeGenPrgv/
在线生成工具:https://whoisdog.com/tool/htpasswd-generator/
添加转写规则,强制加密访问:
编辑:/usr/local/nginx/conf/rewrite/webdav.com.conf
if ($server_port !~ "^443$"){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite ^/.*$ https://$server_name$uri redirect; }
【设置】
主要设置项目包括:
1. 网址:webdav.com
2. 协议/端口:http:// 80 ;https:// 443
3. 用户/密码
【软件】
Windows自带文件管理器:
文件管理器 可以上传;IE/FF 可以浏览
RaiDrive软件:
链接:https://pan.baidu.com/s/1loF-kKEYqYOcEDvQd03GyA
提取码:xou3
Linux
Mount方法:(需要安装davfs2,注意权限)
sudo apt-get install davfs2 sudo mount -t davfs http://webdav.cn:8000 /home/user/webdav/
客户端方法:
sudo apt-get install cavader Cavader http://webdav.cn:8000
参考:https://www.cnblogs.com/herryzz/p/10522749.html
参考:https://www.cnblogs.com/longware/p/4511599.html?ptvd
【排错】
报错:./configure: error: the HTTP XSLT module requires the libxml2/libxslt
参考:https://blog.csdn.net/lemqs0123/article/details/105942882
yum install libxml2 libxml2-devel libxslt libxslt-devel
【参考】
编译:https://www.cnblogs.com/Dy1an/p/11227796.html
编译:https://blog.csdn.net/zsx0728/article/details/103777226
编译:https://www.cnblogs.com/tinywan/p/6965467.html