WebDAV

https://en.wikipedia.org/wiki/WebDAV

https://caddyserver.com/docs/http.webdav

https://blog.sleeplessbeastie.eu/2017/09/04/how-to-mount-webdav-share/

协议接口简单,无需配置,无需挂载,符合我的口味,HTTP GET/PUT 即可完成 读/写 操作。

实际常用就两个方法,curl 描述:

下载:

curl http://webdav.server/YOUR/FILE/NAME

上传(本质上就是 PUT with raw-file-content):

curl -T YOUR-LOCAL-FILE http://webdav.server/YOUR/FILE/NAME
# or
curl -X PUT --data-binary @YOUR-LOCAL-FILE http://webdav.server/YOUR/FILE/NAME

创建目录,列出目录,删除,重命名等操作,权限控制等,去翻文档。

Windows/Linux/macOS 皆可直接挂载(不推荐生产环境用此方法)。

如 Linux:

yum install davfs2
mount -t davfs http://webdav.foo.bar/ /mnt/dav

/etc/davfs2/secrets 内可选编辑相关账号密码。

/etc/fstab 可以设置自动挂载:

https://webdav.tyio.net/ /mnt/dav davfs noauto,user,uid=q 0 0

Windows:

net use * http://webdav.foo.bar/

或者使用 WinSCP

最后, 推荐 rclone,它的子命令 mount 调用 fusermount 帮你挂载好。

部署服务

若使用 Caddy 作为其服务器,部署简单,单服务实例连续读写性能不输 NFS。性能扩展简单,很容易打满网络与磁盘。

http:// {
    webdav {
        scope /data
    }
    gzip
    log / stderr "{when_iso}	{remote}	{method}	{uri}	{proto}	{status}	{size}	{latency}	{>Content-Length}	{>User-Agent}"
}

可直接伺服,也可以选择用 nginx 代理,注意配置优化:

proxy_buffering off;
proxy_request_buffering off;

还有 https://github.com/hacdias/webdav 可选,目前我的 lwzm/webdav 就改用这个程序。