WebDAV 是 GitHub 上开源的项目,基于 Go 语言实现,不仅跨平台,还支持 ARM 架构,可在㠌入式设备中部署 WebDAV 服务器。

项目地址:https://github.com/hacdias/webdav

在 GitHub 下载对应的架构 WebDAV,如:windows-amd64-webdav.zip 。解压后获得 webdav.exe 。

用文本编辑器新建 config.yaml 文件,内容如下:

# 监听任意网卡,多网卡可指定对应ip
address: 0.0.0.0
port: 8081
# 如果无需验证填 false
auth: true
# 如果不需要 https 则填 false
tls: true
# https证书和密钥,如果 tls 为 false,cert 和 key 不需要
cert: /data/www/cert/szhome.xf1024.com_nginx/cert.pem
key: /data/www/cert/szhome.xf1024.com_nginx/cert.key
# 访问前缀,建议默认
prefix: /

# 如果 auth 为 false 生效,文件共享的路径
scope: /data/users/public
# 是否允许修改
modify: true
rules: []

# 跨域设置
cors:
  enabled: true
  credentials: true
  allowed_headers:
    - Depth
  allowed_hosts:
    - http://localhost:8081
  allowed_methods:
    - GET
  exposed_headers:
    - Content-Length
    - Content-Range

# 用户信息,如果 auth 为 true 生效
users:
  - username: user1
    password: 123456
    scope: /data/users/2021
  - username: user2
    password: 654321
    scope: /data/users/2022

注意 yaml 文件格式的书写规则,users 下是需认证的用户名,密码,及用户共享文件。

使用时使用命令:

webdav -c ./config.yaml