L40※ Linux部署webdav服务

1> 下载配置WebDav

开源地址为:https://github.com/hacdias/webdav

mkdir /data/webdav
mkdir /usr/local/webdav && cd /usr/local/webdav
wget https://mirrors.condor.vip/webdav/v5.3.0/linux-amd64-webdav.tar.gz
tar -xvzf linux-amd64-webdav.tar.gz

vim config.yaml

# Server related settings
address: 0.0.0.0
port: 8369
auth: true
tls: false
cert: cert.pem
key: key.pem

# Default user settings (will be merged)
prefix: /
debug: false
noSniff: false
directory: .
permissions: RCUD
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:
  enabled: true
  credentials: true
  allowed_headers:
    - Depth
  allowed_hosts:
    - http://localhost:8369
  allowed_methods:
    - GET
    - POST
    - PUT
    - DELETE
  exposed_headers:
    - Content-Length
    - Content-Range


users:
  - username: hailey
    password: "{bcrypt}$2b$12$HdlmiV49IEthUuzBcUVFZ.A6h3IKpCO.IW1rrFKX7EJobuXD1NqoS"
    directory: /data/webdav
# 生成加密的密码,用于"{bcrypt}$2b$12$HdlmiV49IEthUuzBcUVFZ.A6h3IKpCO.IW1rrFKX7EJobuXD1NqoS"
import bcrypt
# 创建哈希密码
password = b"password"
salt = bcrypt.gensalt(rounds=12)  # 生成随机盐
hashed_password = bcrypt.hashpw(password, salt)
print("Hashed password:", hashed_password)

对外服务的端口号为8369,端口可以自行更改,需要在安全组里放开;webdav的存储目录为/data/webdav

2> 添加服务

vim /usr/lib/systemd/system/webdav.service

[Unit]
Description=WebDAV server
After=network.target

[Service]
Type=simple
User=root
ExecStart=/usr/local/webdav/webdav --config /usr/local/webdav/config.yaml
Restart=on-failure

[Install]
WantedBy=multi-user.target

3> 开放防火墙端口

4> 启动WebDav服务

systemctl daemon-reload
systemctl enable webdav
systemctl start webdav
systemctl status webdav

5> windows 通过映射网络驱动挂载webdav

使用Windows 添加webdav服务器时出现:输入的文件夹似乎无效,请选择另一个

  1. 打开注册表编辑器,打开HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Services -> WebClient -> Parameters项,修改BasicAuthLevel的值为2 (原来为1)
  2. 重启WebClient服务

命令行中提示:“系统找不到指定的驱动器”

  1. 打开注册表编辑器,打开HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Windows -> CurrentVersion -> Policies -> System项,新建名称为EnableLinkedConnections的DWORD(32bit)项,将其值修改为1
  2. 重启电脑
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享