1. 安装rclone并设置网盘(略过)
  2. 安装docker(略过)

新建一个脚本存放目录

mkdir /root/up


安装qbittorrent

1、拉取镜像

docker pull linuxserver/qbittorrent

2、创建对应目录并编写 Docker-Compose 文件

cd ~
mkdir qBittorrent #创建qbitorrent数据文件夹
cd qBittorrent
mkdir config downloads #创建配置文件目录与下载目录
nano docker-compose.yml #创建并编辑文件

3、复制如下内容并按需修改:

version: "2"
services:
qbittorrent:
image: linuxserver/qbittorrent
container_name: qbittorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai # 你的时区
- UMASK_SET=022
- WEBUI_PORT=8080 # 将此处修改成你欲使用的 WEB 管理平台端口
volumes:
- ~/qBittorrent/config:/config # 绝对路径请修改为自己的config文件夹
- ~/qBittorrent/downloads:/downloads # 绝对路径请修改为自己的downloads文件夹
ports:

  # 要使用的映射下载端口与内部下载端口,可保持默认,安装完成后在管理页面仍然可以改成其他端口。

- 53808:53808
- 53808:53808/udp

  # 此处WEB UI 目标端口与内部端口务必保证相同

- 8080:8080
restart: unless-stopped

4、执行docker-compose

docker-compose up -d # docker-compose

执行后,访问 ip:web-ui-port 即可进入管理页面。
默认用户名密码admin/adminadmin


安装qbittorrent上传脚本

cd /root/up

新建脚本

nano /root/up/qbittorrent-up.sh


#! /bin/bash

file=$1

cloudName=gdrive #为rclone挂载名称
cloudFolder=dl #为上传网盘目录

software=/root/up/rclone #注意要写/root/up/绝对目录
transfers=4

if [ -d "${file}" ];then
${software} copy --transfers=$transfers "$1" ${cloudName}:${cloudFolder}/"$2"
elif [ -f "${file}" ]; then
${software} copy "$1" ${cloudName}:${cloudFolder}/
fi


复制rclone 和配置文件到/root/up目录

cp /usr/bin/rclone /root/up
cp /root/.config/rclone/rclone.conf /root/up

给配置文件权限

chmod 777 -R /downloads (此目录为下载qb下载目录,默认为/downloads/)
chmod 777 -R /root
chmod 777 -R /root/up
chmod 777 /root/up/qbittorrent-up.sh
chmod 777 /root/up/rclone
chmod 777 /root/up/rclone.conf


设置自动上传

勾选Torrent完成时运行外部程序并填写

/root/up/qbittorrent-up.sh "%F" "%N"

勾选Torrent完成时运行外部程序并填写

qbittorrent-up.sh脚本下载地址

后记:qbittorrent反代设置

location / {
proxy_pass http://127.0.0.1:8080;
proxy_hide_header Content-Security-Policy; 
proxy_http_version 1.1;
add_header Front-End-Https on;
proxy_set_header X-Forwarded-Host $server_name:$server_port;
proxy_hide_header Referer;
proxy_hide_header Origin;
}


自启动

nano /etc/systemd/system/qb.service

[Unit]
Description=qBittorrent-nox
After=network.target

[Service]
User=root
Type=forking
RemainAfterExit=yes
ExecStart=/root/qbittorrent-nox -d

[Install]
WantedBy=multi-user.target