我有一个装有 Ubuntu 18.04.3 LTS 的工作站。我还有一个装有 nginx + WebDAV 的远程服务器。(它位于 FreeBSD 下,但似乎并不重要。)我使用以下命令配置了工作站上 webdav 共享的安装本手册. 一切都进展顺利。
但是,有一天,我发现它停止工作了:( 看起来像是一个安装错误:
$ sudo mount -t davfs https://site.domain.com:8888 /mnt/RemoteStorage/
Please enter the username to authenticate with server
https://site.domain.com:8888 or hit enter for none.
Username: myuser
Please enter the password to authenticate user myuser with server
https://site.domain.com:8888 or hit enter for none.
Password:
/sbin/mount.davfs: mounting failed; the server does not support WebDAV
服务器端一切看起来都很正常:
123.45.67.89 - - [16/Nov/2019:23:29:53 +0300] "OPTIONS / HTTP/1.1" 401 179 "-" "davfs2/1.5.4 neon/0.30.2" "-"
123.45.67.89 - myuser [16/Nov/2019:23:29:53 +0300] "OPTIONS / HTTP/1.1" 200 0 "-" "davfs2/1.5.4 neon/0.30.2" "-"
我们看到客户端首先发送了一个没有授权的请求,然后被拒绝(401),然后它再次发送了授权请求并得到了 OK(200)。这种行为似乎很正常。
我打开了 davfs2 调试并在日志中看到以下内容(从出现 401 那一刻开始引用):
..
Nov 16 21:38:36 Station2 mount.davfs: auth: Got challenge (code 401).
Nov 16 21:38:36 Station2 mount.davfs: auth: Got 'Basic' challenge.
Nov 16 21:38:36 Station2 mount.davfs: auth: Trying Basic challenge...
Nov 16 21:38:36 Station2 mount.davfs: auth: Accepted Basic challenge.
Nov 16 21:38:36 Station2 mount.davfs: Running pre_send hooks
Nov 16 21:38:36 Station2 mount.davfs: auth: Sending 'Basic' response.
Nov 16 21:38:36 Station2 mount.davfs: Sending request headers:#012OPTIONS / HTTP/1.1#015#012User-Agent: davfs2/1.5.4 neon/0.30.2#015#012Keep-Alive: #015#012Connection: TE, Keep-Alive#015#012TE: trailers#015#012Host: site.domain.com:8888#015#012Authorization: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Nov 16 21:38:36 Station2 mount.davfs: Sending request-line and headers:
Nov 16 21:38:36 Station2 mount.davfs: Request sent; retry is 1.
Nov 16 21:38:36 Station2 mount.davfs: [status-line] < HTTP/1.1 200 OK
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Server: nginx/1.16.1
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [server], Value: [nginx/1.16.1]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Date: Sat, 16 Nov 2019 18:38:36 GMT
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [date], Value: [Sat, 16 Nov 2019 18:38:36 GMT]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Content-Length: 0
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [content-length], Value: [0]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Connection: keep-alive
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [connection], Value: [keep-alive]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] DAV: 2
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [dav], Value: [2]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Allow: GET,HEAD,PUT,DELETE,MKCOL,COPY,MOVE,PROPFIND,OPTIONS,LOCK,UNLOCK
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [allow], Value: [GET,HEAD,PUT,DELETE,MKCOL,COPY,MOVE,PROPFIND,OPTIONS,LOCK,UNLOCK]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Expires: Thu, 31 Dec 2037 23:55:55 GMT
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [expires], Value: [Thu, 31 Dec 2037 23:55:55 GMT]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Cache-Control: max-age=315360000
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [cache-control], Value: [max-age=315360000]
Nov 16 21:38:36 Station2 mount.davfs: [hdr] Allow: OPTIONS, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND
Nov 16 21:38:36 Station2 mount.davfs: Header Name: [allow], Value: [OPTIONS, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND]
Nov 16 21:38:36 Station2 mount.davfs: [hdr]
Nov 16 21:38:36 Station2 mount.davfs: End of headers.
Nov 16 21:38:36 Station2 mount.davfs: Running post_headers hooks
Nov 16 21:38:36 Station2 mount.davfs: Running post_send hooks
Nov 16 21:38:36 Station2 mount.davfs: ah_post_send (#1), code is 200 (want 401), WWW-Authenticate is (none)
Nov 16 21:38:36 Station2 mount.davfs: Request ends, status 200 class 2xx, error line:#012200 OK
Nov 16 21:38:36 Station2 mount.davfs: Running destroy hooks.
Nov 16 21:38:36 Station2 mount.davfs: Request ends.
事实证明,客户端使用身份验证重复了请求,但是“忘记”了它,并且在收到答案 200 后,却错误地识别了它,因为它期望的是 401。
这一切到底出了什么问题?
PS 我已经安装了 davfs2 1.5.4-2。前几天,我更新了 Ubuntu 软件,但这个包还没有更新(我在 apt 日志中看到)。
PPS 另外,我在 Android 和 Windows 上都有 WebDAV 客户端。它们成功使用了该共享。