Version:webdav v5.4.1

# 介绍

# NFS 协议

NFS(网络文件系统 Network File System)是 TCP/IP 协议集所提供的一种子协议,已然成为 Unix/Linux 类系统的标配。

优点

  • 在 Unix/Linux 环境中性能优异。
  • 配置相对简单,集成在大部分类 Unix 系统中。
  • 支持不同的 NFS 版本,提供向后兼容性。

缺点

  • 权限管理相对简单,对安全性要求高的场景需额外配置。
  • 通常依赖于底层网络的稳定性。

安全性

  • 没有加密授权等功能,仅依靠 IP 地址或主机名来决定用户能否挂载共享目录,对具体目录和文件无法进行 ACL 权限控制(NFSv4 以前)。

常见用途:Unix/Linux 系统间的文件共享、分布式文件系统、HPC(高性能计算)环境。

# Samba 协议

Samba 是 SMB/CIFS(Server Message Block / Common Internet File System)网络协议的重新实现,可以在局域网不同计算机之间进行文件、打印机等资源共享,和 NFS 功能类似。

优点

  • 支持丰富的功能,包括文件和打印共享、用户身份验证和授权。
  • 广泛应用于 Windows 网络环境,集成度高。
  • 提供详细的权限设置和文件锁定机制,支持并发控制。

缺点

  • 相对复杂,可能需要较多的配置和管理。
  • 在大规模网络中,性能可能受限。

安全性

  • 提供端到端加密、安全性高,配置选项丰富,支持 ACL 并支持多种用户认证模式。

常见用途:局域网内的文件共享、打印服务、企业内部网络存储。

# WebDAV 协议

WebDAV(Web-based Distributed Authoring and Versioning)是基于 HTTP1.1 协议的拓展升级版,可以很方便的跨越网关、防火墙。使得在公网上访问特别简单,并且通过 https 的公网访问拥有非常棒的安全性。

优点

  • 基于 HTTP 协议,广泛兼容。
  • 提供文件锁定机制,支持多人协作。
  • 支持元数据(属性)的存储和管理。

缺点

  • 性能相比专用文件系统协议稍差。
  • 安全性依赖于 HTTP 的基础设施(如 SSL/TLS)。

安全性

  • 协议本身并没有提供加密功能,但可以通过使用 HTTPS 协议来保障数据传输的安全性;另外,支持身份验证和权限控制,可以设置访问权限,从而保障数据的安全性。

常见用途:远程文件编辑、网络存储解决方案(如云端存储)。

因此,在了解了上面常规的文件服务挂载协议后,对于远程数据访问,这里就可以使用 webdav 文件服务,关于该服务的搭建可以使用:https://github.com/hacdias/webdav

# 安装

建立存放路径及生成配置文件:

# $WEBDAV_PATH 为你 webdav 部署共享的路径
mkdir -p /app/webdav /<$WEBDAV_PATH>
cd /app/webdav
vim config.yml

添加配置:

config.yml
address: 0.0.0.0
port: 8081
# TLS-related settings if you want to enable TLS directly.
tls: false
cert: cert.pem
key: key.pem
# Prefix to apply to the WebDAV path-ing. Default is '/'.
prefix: /
# Enable or disable debug logging. Default is 'false'.
debug: false
# Disable sniffing the files to detect their content type. Default is 'false'.
noSniff: false
# The directory that will be able to be accessed by the users when connecting.
# This directory will be used by users unless they have their own 'directory' defined.
# Default is '.' (current directory).
directory: .
# The default permissions for users. This is a case insensitive option. Possible
# permissions: C (Create), R (Read), U (Update), D (Delete). You can combine multiple
# permissions. For example, to allow to read and create, set "RC". Default is "R".
permissions: R
# The default permissions rules for users. Default is none.
rules: []
# Logging configuration
log:
  # Logging format ('console', 'json'). Default is 'console'.
  format: console
  # Enable or disable colors. Default is 'true'. Only applied if format is 'console'.
  colors: true
  # Logging outputs. You can have more than one output. Default is only 'stderr'.
  outputs:
  - stderr
# CORS configuration
cors:
  # Whether or not CORS configuration should be applied. Default is 'false'.
  enabled: false
  credentials: false
  allowed_headers:
    - Depth
  allowed_hosts:
    - http://localhost:8081
  allowed_methods:
    - GET
  exposed_headers:
    - Content-Length
    - Content-Range
# The list of users. If the list is empty, then there will be no authentication.
# Otherwise, basic authentication will automatically be configured.
#
# If you're delegating the authentication to a different service, you can proxy
# the username using basic authentication, and then disable webdav's password
# check using the option:
#
# noPassword: true
users:
  # Example 'john' user with bcrypt encrypted password, with custom directory.
  - username: john
    password: "{bcrypt}$2y$10$zEP6oofmXFeHaeMfBNLnP.DO8m.H.Mwhd24/TOX2MWLxAExXi4qgi"
    directory: /data

运行 Docker:

docker pull hacdias/webdav:latest
docker run -d \
  --name webdav \
  -v /<$WEBDAV_PATH>/:/data \
  -v /app/webdav/config.yml:/webdav_config.yml:ro \
  -p 6065:8081 \
  -e TZ=Asia/Shanghai \
  --restart always \
  ghcr.io/hacdias/webdav \
  -c /webdav_config.yml

参数解释:

  • -v /app/webdav/config.yml:/webdav_config.yml:ro :将主机的 config.yml 配置文件映射为容器的 /webdav_config.yml 文件,用于启动参数的获取。
  • -p 6065:8081 :将容器的 8081 端口映射到主机的 6065 端口,使得 webdav 的 Web 界面可以通过主机的端口访问。
  • -c /webdav_config.yml :通过传参命令,指定读取(容器内路径)启动参数配置。

# 使用

通过专用的 webdav 挂载工具,输入地址加端口,在登录的时候,根据 webdav_config.yml 中的 users: 字段,选择不同的用户登录,则链接到不同的挂载访问路径。

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

夏沫の浅雨 微信支付

微信支付

夏沫の浅雨 支付宝

支付宝