webdav 服务器
基于 http 协议, 速度还算比较快, 最方便的是: 如果是使用 MacOS, 可以直接用 Finder 链接, 如果是 windows 可以使用资源管理器链接, 不用额外安装其他客户端
- ugeek/webdav 基于 Nginx 的 webdav, 最容易配置, 速度快, 支持的平台多(amd/arm/Raspberry等都支持)
- difeid/webdav-server-rs Rust 版本的 webdav-server, 速度非常快(更多功能正在开发中, 可尝鲜体验)
- hacdias/webdav Go语言版本的 webdav 实现, 体积小, 速度较快
- bytemark/webdav 基于 Apache 的 webdav 镜像, 虽然下载次数多, 实测容易崩溃, 下载速度也不如其他
yaml
services:
webdav-server:
image: ugeek/webdav:amd64 # 注意CPU指令集平台tag
container_name: webdav-server
restart: always
ports:
- 8080:80
volumes:
- ./data:/media
environment:
- USERNAME=admin
- PASSWORD=admin123456 # 注意修改密码
- TZ=Asia/Shanghai
- UDI=1000
- GID=1000Rust 版本的 webdav-server, 可尝鲜体验
在MacOS中不知道为什么可以用 Finder 链接, 却无法用 Cyberduck 链接
txt
.
├── config 配置目录
│ ├── htpasswd.conf 账户验证配置
│ └── webdav-server.toml 服务核心配置
├── data 文件存放目录
│ └── 1.txt
└── docker-compose.yaml docker-compose配置文件
3 directories, 4 filesyaml
services:
webdav-server-rs-app:
image: difeid/webdav-server-rs:latest
restart: always
ports:
- 8080:4918
volumes:
- ./data:/data
- ./config:/configtoml
# Webdav server settings.
# docs: https://github.com/difeid/webdav-server-rs
[server]
listen = [ "0.0.0.0:4918", "[::]:4918" ]
uid = 33
gid = 33
identification = "webdav-server-rs"
[accounts]
auth-type = "htpasswd.conf"
acct-type = "unix"
realm = "Webdav Server"
[htpasswd.conf]
htpasswd = "/config/htpasswd.conf"
# username: admin
# password: admin123456
# generate htpasswd file online: https://hostingcanada.org/htpasswd-generator/#password
[unix]
cache-timeout = 120
min-uid = 1000
supplementary-groups = false
[[location]]
route = [ "/*path" ]
methods = [ "webdav-rw" ]
auth = "opportunistic"
handler = "filesystem"
on_notfound = "return"
setuid = false
directory = "/data" # webdav file save path
autoindex = true
hide-symlinks = true
case-insensitive = "false"txt
admin:$2y$10$gW9pdANvbPaYTe2kdSGlxu4ghKtd2Kuq1QC/8Tyw/nPBHPBcUEM1.
user2:$2y$10$gW9pdANvbPaYTe2kdSGlxu4ghKtd2Kuq1QC/8Tyw/nPBHPBcUEM1.ftp 服务器
- fauria/vsftpd 简洁易用
- vsftpgo 功能更丰富,但是配置也更复杂一些
传输速度快但功能简单
yaml
services:
vsftpd:
image: fauria/vsftpd:latest
container_name: vsftpd
restart: always
ports:
# 链接的时候注意端口
- "2020:20"
- "2021:21"
- "20000:20000"
volumes:
- "./data:/home/vsftpd"
environment:
FTP_USER: admin # 登录账号
FTP_PASS: admin123456 # 注意修改密码
PASV_MIN_PORT: 20000
PASV_MAX_PORT: 20000
PASV_ADDRESS: 127.0.0.1 # 注意修改,FTP服务地址,默认使用宿主机地址nextcloud
功能丰富的开源网盘系统, 社区活跃, 服务端主要用 PHP 实现, 缺点是速度堪忧
yml
networks:
nextcloud-net:
services:
db:
image: mysql:8
container_name: nextcloud_mysql8
restart: always
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
ports:
- "3306:3306"
networks:
- nextcloud-net
volumes:
- ./mysql_data:/var/lib/mysql
- ./mysql_conf:/etc/mysql # 如果不手动修改配置, 请注释这行, 否则会报错
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: root1314
MYSQL_PASSWORD: nextcloud
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
app:
image: nextcloud:stable
container_name: nextcloud_app
restart: always
depends_on:
- db
ports:
- 8080:80
networks:
- nextcloud-net
volumes:
- ./nextcloud:/var/www/html
environment:
MYSQL_PASSWORD: nextcloud
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_HOST: dbseafile
适合备份同步/协作编辑文件, 可看作开源版的坚果云
yaml
networks:
seafile-net:
services:
db:
image: mariadb:10.11
restart: always
container_name: seafile-mysql
hostname: database_server
environment:
MYSQL_ROOT_PASSWORD: root-password # mysql 服务 root 用户密码
MYSQL_LOG_CONSOLE: true
volumes:
- ./seafile-mysql:/var/lib/mysql # mysql 数据
networks:
- seafile-net
memcached:
image: memcached:1.6 # 缓存服务
restart: always
container_name: seafile-memcached
entrypoint: memcached -m 256
networks:
- seafile-net
seafile:
image: seafileltd/seafile-mc:11.0.1 # 注意版本
restart: always
container_name: seafile
volumes:
- ./seafile-data:/shared
ports:
- "80:80"
#- "443:443" # 是否使用 https 协议
environment:
DB_HOST: database_server
DB_ROOT_PASSWD: root-password
TIME_ZONE: Asia/Shanghai
SEAFILE_ADMIN_EMAIL: your_email@example.com # 管理员账号邮箱
SEAFILE_ADMIN_PASSWORD: your_admin_password # 管理员账号密码
SEAFILE_SERVER_LETSENCRYPT: false
SEAFILE_SERVER_HOSTNAME: seafile.example.com # 你的域名(csrf)
depends_on:
- db
- memcached
networks:
- seafile-netcloudreve
速度非常快, 开源版本的百度网盘
sh
# 创建 docker 项目工作目录
mkdir cloudreve-driver
cd cloudreve-driver
# 创建 docker-compose.yaml 配置文件
touch docker-compose.yaml
# 创建 cloudreve 数据存放目录和一些配置文件
mkdir data && \
mkdir cloudreve && \
mkdir cloudreve/{uploads,avatar} && \
touch cloudreve/conf.ini && \
touch cloudreve/cloudreve.db && \yaml
services:
cloudreve:
container_name: cloudreve
image: cloudreve/cloudreve:latest
restart: unless-stopped
ports:
# 如果部署在 阿里云/腾讯云 需要在安全组中开放端口
- "12000:5212"
volumes:
- temp_data:/data
- ./cloudreve/uploads:/cloudreve/uploads
- ./cloudreve/avatar:/cloudreve/avatar
- ./cloudreve/conf.ini:/cloudreve/conf.ini
- ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
depends_on:
- aria2
aria2:
container_name: aria2
image: p3terx/aria2-pro
restart: unless-stopped
environment:
# 注意修改这个密码
RPC_SECRET: your_password
RPC_PORT: 6800
volumes:
- ./aria2/config:/config
- temp_data:/data
volumes:
temp_data:
driver: local
driver_opts:
type: none
device: $PWD/data
o: bindrustfs
- 什么是 rustfs
rustfs Rust语言开发的高性能分布式对象存储软件, 其实就是开源版本的 oss/s3 服务实现
- 部署它有什么作用
有些时候, 需要测试 oss/s3 上传, 但是又没有开通对应的服务(付费的), 开发时就可以使用这个做为替代
yaml
services:
rustfs:
image: rustfs/rustfs:latest
container_name: rustfs-server
security_opt:
- "no-new-privileges:true"
ports:
- "9000:9000" # S3 API 对外端口
- "9001:9001" # 控制台对外端口
environment:
# 数据卷(多个路径用逗号分隔)
- RUSTFS_VOLUMES=/data/rustfs0
# API 和控制台监听地址
- RUSTFS_ADDRESS=0.0.0.0:9000
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9001
- RUSTFS_CONSOLE_ENABLE=true
# CORS 设置,控制台与 S3 API 都放开来源
- RUSTFS_CORS_ALLOWED_ORIGINS=*
- RUSTFS_CONSOLE_CORS_ALLOWED_ORIGINS=*
# 访问密钥(生产环境请修改为强密码)
- RUSTFS_ACCESS_KEY=rustfsadmin # 注意修改登录用户名
- RUSTFS_SECRET_KEY=rustfsadmin # 注意修改登录账户密码
# 日志级别
- RUSTFS_OBS_LOGGER_LEVEL=info
volumes:
# 存储数据卷(请根据实际情况修改路径)
- ./deploy/data/pro:/data
# 日志目录
- ./deploy/logs:/app/logs
# networks:
# - rustfs-network
restart: unless-stopped
healthcheck:
test: ["CMD", "sh", "-c", "curl -f http://localhost:9000/health && curl -f http://localhost:9001/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# networks:
# rustfs-network:
# driver: bridge
# ipam:
# config:
# - subnet: 172.20.0.0/16部署私人音乐服务
- navidrome: 私人音乐服务
- rclone + fuse: 用于将oss服务挂载到本地目录(可以将音乐文件存放在oss服务中, 而不是服务器)
- 安装必要的软件
sh
sudo apt install -y rclone
sudo apt install -y fuse3- 修改 fuse 配置文件
sudo nvim /etc/fuse.conf
取消注释
txt
# The file /etc/fuse.conf allows for the following parameters:
#
# user_allow_other - Using the allow_other mount option works fine as root, but
# in order to have it work as a regular user, you need to set user_allow_other
# in /etc/fuse.conf as well. This option allows non-root users to use the
# allow_other option. You need allow_other if you want users other than the
# owner of a mounted fuse to access it. This option must appear on a line by
# itself. There is no value; just the presence of the option activates it.
user_allow_other
# mount_max = n - this option sets the maximum number of mounts.
# It must be typed exactly as shown (with a single space before and after the
# equals sign).
#mount_max = 1000- 修改 rclone 配置文件
sudo nvim ~/.config/rclone/rclone.conf
添加一个 remote, 注意修改参数
txt
[aliyun-oss]
type = s3
acl = private
storage_class = STANDARD
bucket_object_lock_enabled = true
provider = Alibaba
access_key_id = your_access_key_id
secret_access_key = your_access_key_id
endpoint = oss-cn-shenzhen.aliyuncs.com- 初始化 navidrome 项目
sh
mkdir navidrome-server && cd -
mkdir data && mkdir music@mount
touch mount.sh
touch unmount.shtxt
.
├── data # 服务数据存放目录
├── docker-compose.yaml # docker-compose 配置文件
├── music@mount # 被挂载的目录(映射到容器中)@mout标记挂载目录没有其他涵义
├── rclone_mount.log # rclone 挂载脚本执行日志
├── mount.sh # rclone 挂载脚本
└── unmount.sh # rclone 取消挂载脚本
3 directories, 4 filesyaml
services:
navidrome:
image: deluan/navidrome:latest
container_name: navidrome-server
restart: unless-stopped
ports:
- "8003:4533"
environment:
# Optional: put your config options customization here. Examples:
# https://www.navidrome.org/docs/usage/configuration/options/
ND_LOGLEVEL: info
volumes:
- "./data:/data"
- "./music@mount:/music:ro"sh
#!/bin/bash
# rclone mount command
rclone mount aliyun-oss:/Music ./music@mount --daemon --allow-other --vfs-cache-mode full --dir-cache-time 10m --attr-timeout 1s --log-file ./rclone_mount.logsh
#!/bin/bash
# rclone unmount command
fusermount -u ./music@mount- 启动服务 & 停止服务
sh
# 启动服务: 先挂载目录在启动 docker 服务
./mount.sh
docker compose up -d
# 停止服务: 先卸载目录在停止 docker 服务
./unmount.sh
docker compose down扩展将 mount.sh 脚本作为系统服务
- 创建系统服务文件
sudo touch /etc/systemd/system/rclone-mount.service
txt
[Unit]
Description=Rclone Mount Service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
# 注意脚本的绝对路径
ExecStart=/home/dev/navidrome-server/mount-srv-ctl.sh start
ExecStop=/home/dev/navidrome-server/mount-srv-ctl.sh stop
Restart=on-failure
RestartSec=10
# 以特定用户运行(假设你的用户名是 dev)
User=dev
# 防止因服务崩溃导致循环重启过频繁
StartLimitInterval=60
StartLimitBurst=3
[Install]
WantedBy=multi-user.target- 创建
mount-srv-ctl.sh控制脚本
touch /home/dve/navidrome-server/mount-srv-ctl.sh
sh
#!/bin/bash
WORK_DIR="/home/dev/navidrome-server"
# your rclone remote
REMOTE="your-rolone-webdav:/music"
# mount point directory
MOUNT_POINT="$WORK_DIR/music@mount"
function start() {
if mountpoint -q "$MOUNT_POINT"; then
echo "$MOUNT_POINT is mounted"
exit 0
fi
echo "start rclone mounting...."
exec rclone mount \
--config=/home/dev/.config/rclone/rclone.conf \
--vfs-cache-mode full --dir-cache-time 10m --attr-timeout 1s \
--allow-other \
--log-file=$WORK_DIR/rclone_mount.log \
--log-level INFO \
"$REMOTE" "$MOUNT_POINT"
}
function stop() {
echo "stop rclone mounting...."
fusermount -u -z "$MOUNT_POINT" 2>/dev/null || true
sleep 1
}
function status() {
if mountpoint -q "$MOUNT_POINT"; then
echo "$MOUNT_POINT is mounted"
exit 0
else
echo "$MOUNT_POINT is not mounted"
exit 1
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac- 使用系统服务的方式挂载而不是手动执行挂载
sh
# 先确保 /home/dev/navidrome-server/music@mount 没有挂载
./unmount.sh
# 启动服务: 挂载目录
sudo systemctl start rclone-mount.service
# 停止服务: 取消挂载
sudo systemctl stop rclone-mount.service
# 查看服务状态
sudo systemctl status rclone-mount.service- 让挂载服务开机自启动(可选)
sh
sudo systemctl enable rclone-mount.service