- 对于Ubuntu执行以下安装NGINX以及支持WebDAV模块:
nginx_webdav/ubuntu_install_nginx_webdav
- 检查
ngnix -V
输出:
nginx_webdav/check_ubuntu_nginx_webdav
macOS中使用 homebrew
安装NGINX默认已经启用了 ( ngx_http_dav_module
),以下是 macos_studio
安装工具软件命令。但是,默认 homebrew
安装的NGINX只提供了 --with-http_dav_module
支持,但是没有 http_ext_module
支持,这会导致 nginx.conf
配置中:
dav_ext_methods PROPFIND OPTIONS;
无法识别,启动nginx时日志提示:
2023/02/13 16:31:56 [emerg] 29049#0: unknown directive "dav_ext_methods" in /usr/local/etc/nginx/nginx.conf:52
这个问题必须解决,否则在 joplin_sync_webdav
,WebDAV客户端执行 MKCOL
/ PROPFIND
会报错返回 405
返回码
要能够支持 joplin_sync_webdav
,需要自己 build_nginx_macos
支持第三方模块 ngx_http_dav_module
,就能够进行下面的配置
Note
本段实践为 joplin_sync_webdav
提供支持,在 macos
上采用 homebrew
提供的NGNIX
macos
平台没有采用linux
的PAM认证,采用nginx_basic_auth
的密码文件认证:
nginx_webdav/create_htpasswd
homebrew
提供的NGIX配置/usr/local/etc/nginx/nginx.conf
(brew
安装的NGINX位置可能不同 ) 添加如下段落(我的NGINX监听8080
端口)
nginx_webdav/brew_nginx.conf
重启 NGINX 服务:
brew services restart nginx
- 在
/Users/huatai/docs/joplin
目录下存放一个test_webdav.txt
文件,然后执行不带密码的访问方式:
nginx_webdav/curl_webdav_without_password
提示没有认证的报错:
nginx_webdav/curl_webdav_without_password_output
- 改为提供密码账号方式访问:
nginx_webdav/curl_webdav_with_password
此时提示信息显示认证通过,返回 200
:
nginx_webdav/curl_webdav_with_password_output
去掉上述 curl
命令的 -I
参数,就能看到终端返回 test_webdav.txt
内容:
Hello WebDAV
然后就可以测试 joplin_sync_webdav
- 启动同步后,
Joplin
同步提示错误:
nginx_webdav/joplin_sync_error
- 检查 NGINX 的
access.log
日志:
nginx_webdav/joplin_sync_nginx_access.log
可以看到 405
返回码对应的指令是 MKCOL
和 PROPFIND
,这说明配置中,以下模块选项配置是非常重要的:
dav_ext_methods PROPFIND OPTIONS;
注意,在这个配置前面有一行:
dav_methods PUT DELETE MKCOL COPY MOVE;
表明已经配置允许了 MKCOL
WebDAV指令,但是完整的WebDAV指令支持已经不在NGINX中:
这个问题参考:
- nginx webdav could not open collection : nginx内建的webdav模块已经不在使用,需要使用第三方 nginx-dav-ext-module
- Backing up using webDAV from DAVx⁵ to nginx fails with HTTP 409, HTTP 405 #500 : 通过第三方 nginx-dav-ext-module 可以解决
PROPFIND
实现,建议采用external module
构建这个模块,这样可以按需启用模块无需重复编译NGINX
编译包含 nginx-dav-ext-module 的NGINX
Note
标准的 ngx_http_dav_module 只提供部分WebDAV实现,只支持 GET,HEAD,PUT,DELETE,MKCOL,COPY,MOVE
方法;而 nginx-dav-ext-module 扩展支持了完整的WebDAV方法。
- 采用 ref:build_nginx_macos 方法完成NGINX安装
- 配置文件采用上文