Canary Workshop

Whatever is worth doing at all is worth doing well

服务器端Transmission的替代品:Cloud Torrent

之前为了在校下载文件和下载一些被天朝【哔】掉的资源,我在服务器上搭建了Transmission,表现良好。但Transmission的功能太强大,有许多我用不到的功能,因此我换用了更轻量级的BT客户端Cloud Torrent。这是一个极简的BT客户端,相比Transmission有如下优点:

  • 由Go语言写成,仅有一个二进制文件,极为轻量级
  • 资源占用小
  • 界面简洁易操作
  • 下载完毕后直接给出HTTP链接,更便于拖回本地

这些特性正好符合我的需求,于是我卸载了Transmission换用Cloud Torrent,使用supervisor守护运行,并用nginx作为反向代理以便于访问和添加HTTPS支持。以下步骤在Ubuntu 16.04.3 LTS x64的服务器上测试通过:

下载安装二进制文件:

1
sudo curl https://i.jpillora.com/cloud-torrent! | bash

创建配置文件:

1
2
3
4
5
6
7
8
9
10
11
sudo nano /etc/cloud-torrent.json
---/etc/cloud-torrent.json---
{
"AutoStart": true,
"DisableEncryption": false,
"DownloadDirectory": "/home/dyn/downloads",
"EnableUpload": true,
"EnableSeeding": true,
"IncomingPort": 50007
}
---/etc/cloud-torrent.json---

创建supervisor配置文件:

1
2
3
4
5
6
7
sudo nano /etc/supervisor/conf.d/ct.conf
---/etc/supervisor/conf.d/ct.conf---
[program:ct]
command = cloud-torrent -a "用户名:密码" -c /etc/cloud-torrent.json
autostart = true
autorestart = true
---/etc/supervisor/conf.d/ct.conf---

supervisor启动程序:

1
2
sudo supervisorctl reread
sudo supervisorctl update

ufw开放所需的端口:

1
sudo ufw allow 3000

配置nginx反向代理:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
sudo /usr/local/nginx/conf/nginx.conf
---/usr/local/nginx/conf/nginx.conf的server{}字段---
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
---/usr/local/nginx/conf/nginx.conf的server{}字段---
sudo /usr/local/nginx/site/ct.conf
---/usr/local/nginx/site/ct.conf---
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name ct.dyn.im;
ssl_certificate /usr/local/nginx/ssl/wildcard.crt;
ssl_certificate_key /usr/local/nginx/ssl/wildcard.key;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_dhparam /usr/local/nginx/ssl/dhparam.pem;
ssl_ciphers TLS13-AES-128-GCM-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:EECDH+CHACHA20:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=1576800000;includeSubDomains;preload";
location / {
proxy_pass http://127.0.0.1:3000;
}
location /realtime {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
listen [::]]:80;
server_name ct.dyn.im;
location / {
return 301 https://ct.dyn.im$request_uri;
}
}
---/usr/local/nginx/site/ct.conf---
sudo service nginx reload

至此,Cloud Torrent部署完毕,可以打开浏览器输入上面设置的密码登录了。