图片轮播
买耗材微信:tonerdrum

Centos7中搭建WebDav的服务

百度百科的定义:WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制。
顾名思义,WebDAV主要就是用来做文档的存储的。

项目在Github上的地址:https://github.com/hacdias/webdav
服务器操作系统:Centos7

cd /usr/local/webdav
wget https://github.com/hacdias/webdav/releases/download/v4.0.0/linux-amd64-webdav.tar.gz
tar -xvzf linux-amd64-webdav.tar.gz
rm -rf linux-amd64-webdav.tar.gz

在webdav同级目录下增加config.yaml

mkdir -p /data/webdav
cat << EOF > /usr/local/webdav/config.yaml
# Server related settings
address: 0.0.0.0
port: 51000
auth: true
tls: false
cert: cert.pem
key: key.pem

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

users:
  - username: admin
    password: admin
    scope: /data/webdav
EOF

增加systemd服务

cat << EOF > /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
EOF
systemctl daemon-reload
systemctl enable webdav
systemctl start webdav

查看服务状态

systemctl status webdav
● webdav.service - WebDAV server
   Loaded: loaded (/usr/lib/systemd/system/webdav.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-04-29 17:34:08 CST; 20h ago
 Main PID: 10032 (webdav)
   CGroup: /system.slice/webdav.service
           └─10032 /usr/local/webdav/webdav --config /usr/local/webdav/config.yaml

如果要网址访问,用nginx反向代理即可。

研究过这种,方式,安全性还是不太可靠,建议上证书用TLS访问,或用FRP穿透加密访问

点击数:89