WebDAV 协议

发布时间: 更新时间: 总字数:496 阅读时间:1m 作者: 分享 复制网址

基于Web的分布式编写和版本控制 (WebDAV)是超文本传输协议的扩展,有利于用户间协同编辑和管理存储在万维网服务器文档。

什么事 WebDAV

WebDAV由互联网工程任务组的工作组在RFC 4918中定义。WebDAV协议为用户在服务器上创建、更改和移动文档提供了一个框架。

WebDAV 基于 HTTP 协议的通信协议,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序可对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制。在广域网上共享文件有天然的优势,移动端文件管理APP也大多支持WebDAV协议。

WebDAV Server

实现由很多种,本文介绍基于 https://github.com/hacdias/webdav 的安装、部署和使用

# Server related settings
address: 0.0.0.0
port: 0
auth: true
tls: false
cert: cert.pem
key: key.pem
prefix: /
debug: false

# Default user settings (will be merged)
scope: .
modify: true
rules: []

# CORS configuration
cors:
  enabled: true
  credentials: true
  allowed_headers:
    - Depth
  allowed_hosts:
    - http://localhost:8080
  allowed_methods:
    - GET
  exposed_headers:
    - Content-Length
    - Content-Range

users:
  - username: admin
    password: admin
    scope: /a/different/path
  - username: encrypted
    password: "{bcrypt}$2y$10$zEP6oofmXFeHaeMfBNLnP.DO8m.H.Mwhd24/TOX2MWLxAExXi4qgi"
  - username: "{env}ENV_USERNAME"
    password: "{env}ENV_PASSWORD"
  - username: basic
    password: basic
    modify:   false
    rules:
      - regex: false
        allow: false
        path: /some/file
      - path: /public/access/
        modify: true
webdav -c ./config.yaml
  • Nginx 代理
    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

使用

可以在 windows 或 Linux 挂载 WebDAV 到系统,Linux 示例

sudo apt install davfs2
sudo mount -t davfs http://url/ ./webdav/

支持 WebDAV 的网盘

  • Google drive
  • 坚果云
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数