Skip to content

从零开始的 Seedbox 之旅

Published: at 12:38

入站半年感觉慢慢攒上传还是太累了,于是最终还是摸了个盒子。因为是简单摸一下,我就不用一键脚本了。为了装起来方便,系统选的直接就是 ArchLinux

这篇文章源起于几个月前,现在已经开始吃灰了,所以赶在不续费之前摸完这篇(

安 装
安 装

设置系统语言

https://wiki.archlinux.org/index.php/Locale_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

首先是修改 /etc/locale.gen,将 zh_CN.UTF-8 UTF-8 前面的注释去掉,然后生成 locale

Terminal window
1
sudo locale-gen

最后设置系统 locale

1
sudo localectl set-locale LANG=zh_CN.UTF-8

下一次 ssh 登录就可以正常显示中文了。

调整分区保留大小

Terminal window
1
# 调整为 1%
2
sudo tune2fs -m 1 /dev/sda3

调整系统时间

Terminal window
1
sudo timedatectl set-timezone Asia/Shanghai

延长 sshd 超时

https://www.simplified.guide/ssh/disable-timeout

修改 /etc/ssh/sshd_config

1
TCPKeepAlive no
2
ClientAliveInterval 30
3
ClientAliveCountMax 240

开启 bbr

https://bbs.archlinux.org/viewtopic.php?id=223879

Terminal window
1
# Load the BBR kernel module.
2
echo "tcp_bbr" > /etc/modules-load.d/modules.conf
3
4
# Set the default congestion algorithm to BBR.
5
echo "net.core.default_qdisc=fq" > /etc/sysctl.d/bbr.conf
6
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/bbr.conf

Nginx

Terminal window
1
# 安装 nginx
2
# 不使用 mainline 是为了升级模块方便
3
sudo pacman -S nginx
4
5
# 站点目录
6
sudo mkdir /etc/nginx/conf.d

然后创建第一个网站:

/etc/nginx/conf.d/torrent.conf
1
server {
2
listen 443 ssl http2;
3
4
server_name torrent.mmf.moe;
5
ssl_certificate ssl/mmf.moe.pem;
6
ssl_certificate_key ssl/mmf.moe.key;
7
8
root /usr/share/nginx/html;
9
include site-torrent/*;
10
}

这里我们使用的证书是 Cloudflare 的源证书,相当于只有 Cloudflare 自签的证书,仅在 Cloudflare 到服务器可用,一次可以签 15 年。

qBittorrent

Terminal window
1
sudo pacman -S qbittorrent-nox

然后写入网站配置:

/etc/nginx/site-torrent/qbt.conf
1
location /qbt/ {
2
proxy_pass http://127.0.0.1:18080/;
3
proxy_http_version 1.1;
4
proxy_set_header X-Forwarded-Host \$server_name:\$server_port;
5
6
http2_push_preload on;
7
8
proxy_hide_header Referer;
9
proxy_hide_header Origin;
10
proxy_set_header Referer '';
11
proxy_set_header Origin '';
12
13
add_header X-Frame-Options "SAMEORIGIN";
14
}

最后启动,注意 @ 后面的是你的用户名:

Terminal window
1
sudo systemctl start qbittorrent-nox@mmfmoe
2
sudo systemctl enable qbittorrent-nox@mmfmoe

FlexGet

FlexGet 的用途主要是配合脚本,只下载 Free 的种子。首先是安装:

Terminal window
1
# 安装 Python 3
2
sudo pacman -S python
3
4
# 初始化 venv
5
python -m venv ~/flexget/
6
7
# 安装 FlexGet
8
cd ~/flexget/
9
bin/pip install flexget
10
11
# 创建插件目录
12
mkdir -p ~/.flexget/plugins
13
14
# 下载 NexusPHP 插件
15
curl https://raw.githubusercontent.com/Juszoe/flexget-nexusphp/master/nexusphp.py > ~/.flexget/plugins/nexusphp.py
16
17
# 创建用于存放种子的目录
18
mkdir ~/flexget/torrents
19
20
# 测试
21
~/flexget/bin/flexget --version

然后是配置:

1
web_server:
2
bind: 127.0.0.1
3
port: 3539
4
web_ui: yes
5
base_url: /flexget
6
7
tasks:
8
u2_free:
9
rss:
10
url: "这里填写你的 RSS 链接"
11
other_fields: [link]
12
nexusphp:
13
cookie: "这里填写你的 Cookie"
14
discount:
15
- free
16
- 2xfree
17
seeders:
18
min: 0
19
max: 5
20
hr: no
21
remember: no
22
download: ~/flexget/torrents/
23
24
schedules:
25
- tasks: "u2_free"
26
interval:
27
minutes: 15

接下来是 Nginx 的配置:

/etc/nginx/site-torrent/flexget.conf
1
location /flexget/ {
2
proxy_pass http://127.0.0.1:3539/flexget/;
3
proxy_http_version 1.1;
4
proxy_set_header X-Forwarded-Host \$server_name:\$server_port;
5
6
http2_push_preload on;
7
8
proxy_hide_header Referer;
9
proxy_hide_header Origin;
10
proxy_set_header Referer '';
11
proxy_set_header Origin '';
12
13
add_header X-Frame-Options "SAMEORIGIN";
14
}

最后启动:

Terminal window
1
flexget daemon start --daemonize

rclone

rclone 大家都会用吧,这里就不多说了

总结

至此,需要的软件基本都有了,也就可以正常工作开刷了。自动删种我没弄,因为我想把东西都上传到 Google Drive,但一直偷懒没写自动脚本,就手动来了。不过好在站内的资源也没多到能在我一个上传周期内塞满硬盘就是了(

Arch 配置起来确实省心,哪天我又要弄盒子的时候照着这篇重开一遍就行了((