Docker搭建cloudreve私人网盘 支持离线下载 支持域名访问 更简单了
Cloudreve 可助你即刻构建出兼备自用或公用的网盘服务,通过多种存储策略的支持、虚拟文件系统等特性实现灵活的文件管理体验。
环境构建
重裝
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -d 11 -v 64 -p lion123 -port 22
更新环境
apt update -y && apt upgrade -y && apt install -y curl wget sudo socat
安装 Docker
curl -fsSL https://get.docker.com | sh
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Cloudreve和离线下载构建
创建目录,创建文件
cd /home/ && mkdir cloud && cd cloud && mkdir -vp cloudreve/{uploads,avatar} && touch cloudreve/conf.ini && touch cloudreve/cloudreve.db && mkdir -p aria2/config && mkdir -p data/aria2 && chmod -R 777 data/aria2
创建compose配置文件
cd /home/cloud/ && nano docker-compose.yml
配置Cloudreve代码
version: "3.8"
services:
cloudreve:
container_name: cloudreve
image: cloudreve/cloudreve:latest
restart: unless-stopped
ports:
- "5212:5212"
volumes:
- temp_data:/data
- ./cloudreve/uploads:/cloudreve/uploads
- ./cloudreve/conf.ini:/cloudreve/conf.ini
- ./cloudreve/cloudreve.db:/cloudreve/cloudreve.db
- ./cloudreve/avatar:/cloudreve/avatar
depends_on:
- aria2
aria2:
container_name: aria2
image: p3terx/aria2-pro
restart: unless-stopped
environment:
- RPC_SECRET= KEJILION
- RPC_PORT=6800
volumes:
- ./aria2/config:/config
- temp_data:/data
volumes:
temp_data:
driver: local
driver_opts:
type: none
device: $PWD/data
o: bind
运行
cd /home/cloud && docker-compose up -d
查询初始登录账号密码
docker-compose logs cloudreve
离线下载配置参数
RPC 服务器地址 => http://aria2:6800
RPC 授权令牌 => KEJILION
节点下载目录 => /data
NGINX反向代理到域名
创建nginx目录结构
mkdir -p /home/nginx
touch /home/nginx/nginx.conf
mkdir -p /home/nginx/certs
申请证书
curl https://get.acme.sh | sh
~/.acme.sh/acme.sh --register-account -m [email protected]
~/.acme.sh/acme.sh --issue -d kjlion.ga --standalone
下载证书
~/.acme.sh/acme.sh --installcert -d kjlion.ga--key-file /home/nginx/certs/key.pem --fullchain-file /home/nginx/certs/cert.pem
清除域名证书
~/.acme.sh/acme.sh --remove -d kjlion.ga
手动删除/root/acme目录
进入目录编辑文件
cd /home/nginx/ && nano nginx.conf
反向代理配置,代理指定IP加端口
events {
worker_connections 1024;
}
http {
client_max_body_size 1000m;
#上传限制参数1G以内文件可上传
server {
listen 80;
server_name kjlion.ga;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name kjlion.ga;
ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;
location / {
proxy_pass http://127.0.0.1:5212;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
部署容器
docker run -d --name nginx -p 80:80 -p 443:443 -v /home/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/certs:/etc/nginx/certs -v /home/nginx/html:/usr/share/nginx/html nginx:latest
查看运行状态
docker ps -a
开机自启动
docker update --restart=always nginx
这次搭建我把nginx和云盘服务分开,方便后续其他服务接入nginx,应该是可行的!
版权声明:
作者:KEJILION
链接:https://blog.kejilion.pro/docker-cloudreve/
来源:科技lion官方博客【国内版】
文章版权归作者所有,未经允许请勿转载。
Dow
问一下博主自己将cloud文件夹创建在其它路径下后(文章的步骤都已修改至相同路径)在cloudreve运行时报错怎么办
命令是sudo docker-compose up -d
运行到:
WARN[0000] The “PWD” variable is not set. Defaulting to a blank string.WARN[0000] /home/ubuntu/disk1/cloud/docker-compose.yml: ‘version’ is obsolete
[+] Running 9/9
13.95
aria2 Pulled
completef68caa8ee20a Pull
6.4s
c7339f08e668 Pullcomplete
4.35
51c8c9194dc8 Pullcomplete
2.25
cloudreve Pulled
53.5s
7.1s
579b34f0a95b Pullcomplete/1c3a166ea45d Pullcomplete
8.6s
30.3s
498f59e89101 Pullcomplete
b8fdad2b2dc0 Pullcomplete
46.2s
[+] Running 2/3
Network cloud defaultCreatedCreated
0.2s
/Container aria2
3.0s
Container cloudreve(这里就不行了)
Creating
0.2s
报错如下:
Error response from daemon: failed to populate volume: error while mounting volume ‘/var/lib/docker/volumes/cloud temp_data/ data’:failed to mountlocal volume: mount /data:/var/lib/docker/volumes/cloud_temp_data/_data, flags: 0x1000: no such file or directory
KEJILION@Dow
GPT会的
qq
想拿来同时做离线和从机怎么搞 就按这个教程弄好后直接改Cloudreve配置文件变从机然后重启吗?
qq
搞定了 但是离线完了还需要转存 唉 好慢啊
lexin
私服云盘,最大的问题其实是内网穿透,这部分技术可以分享一下吗?有咩有当下最好的内网穿透方案呢?
KEJILION@lexin
这方面不熟悉
rh
请问一下,用一键生成的cloudreve,配置文件位置在哪的?
KEJILION@rh
目录地址: /home/docker