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 xxxx@gmail.com
~/.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
进入目录编辑文件
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
Docker常用命令
https://kejilion.blogspot.com/2023/02/docker.html
这次搭建我把nginx和云盘服务分开,方便后续其他服务接入nginx,应该是可行的!
评论
发表评论