基于aria2搭建自己的离线下载服务器

in #cn4 years ago

上个月我的迅雷会员又到期了,这个从大学陪伴到现在的迅雷账号,去年年初就没有再续费,因为迅雷的离线下载服务越来越差了。但是去年下半年需要下载的时候,网速太慢,想折腾aria2,但是当时实在是太忙了,就又开了几个月的会员。

这次到期,正好有些时间,就简单的研究下搭建aria2,正好新购置了一台服务器 => https://1hour.win/archives/98,就用这台来当做我的离线下载服务器吧。又是国外的服务器,有时候下载国外的资源,还是得国外的服务器。

aria2 是一个命令行工具,功能极度强大,下面是其功能列表:

  • Command-line interface
  • Download files through HTTP(S)/FTP/SFTP/BitTorrent
  • Segmented downloading
  • Metalink version 4 (RFC 5854) support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink version 3.0 support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink/HTTP (RFC 6249) support
  • HTTP/1.1 implementation
  • HTTP Proxy support
  • HTTP BASIC authentication support
  • HTTP Proxy authentication support
  • Well-known environment variables for proxy: http_proxy, https_proxy, ftp_proxy, all_proxy and no_proxy
  • HTTP gzip, deflate content encoding support
  • Verify peer using given trusted CA certificate in HTTPS
  • Client certificate authentication in HTTPS
  • Chunked transfer encoding support
  • Load Cookies from file using the Firefox3 format, Chromium/Google Chrome and the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Save Cookies in the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Custom HTTP Header support
  • Persistent Connections support
  • FTP/SFTP through HTTP Proxy
  • Download/Upload speed throttling
  • BitTorrent extensions: Fast extension, DHT, PEX, MSE/PSE, Multi-Tracker, UDP tracker
  • BitTorrent WEB-Seeding. aria2 requests chunks more than piece size to reduce the request overhead. It also supports pipelined requests with piece size.
  • BitTorrent Local Peer Discovery
  • Rename/change the directory structure of BitTorrent downloads completely
  • JSON-RPC (over HTTP and WebSocket)/XML-RPC interface
  • Run as a daemon process
  • Selective download in multi-file torrent/Metalink
  • Chunk checksum validation in Metalink
  • Can disable segmented downloading in Metalink
  • Netrc support
  • Configuration file support
  • Download URIs found in a text file or stdin and the destination directory and output file name can be specified optionally
  • Parameterized URI support
  • IPv6 support with Happy Eyeballs
  • Disk cache to reduce disk activity

功能很强大,但是使用起来,对于新手来说,参数太多了。

经过搜索,找到了一个 docker 版的部署方案,对于会 docker 的 aria2 新手来说太友好了。

docker run -d \
    --name aria2-pro \
    --restart unless-stopped \
    --log-opt max-size=1m \
    -e PUID=$UID \
    -e PGID=$GID \
    -e UMASK_SET=022 \
    -e RPC_SECRET=<TOKEN>  \
    -e RPC_PORT=6800 \
    -p 6800:6800 \
    -e LISTEN_PORT=6888 \
    -p 6888:6888 \
    -p 6888:6888/udp \
    -v /data/aria2-config:/config \
    -v /data/aria2-downloads:/downloads \
    p3terx/aria2-pro

其中,/data/ 目录是我的宿主机目录,最终下载的文件都存储在这里 /data/aria2-downloads,把 <TOKEN> 换成自己定义的字符串,用于作为 RPC 接口的验证。

其他具体详细的参数说明参照这里 => https://github.com/P3TERX/Aria2-Pro-Docker#parameters

上面的容器启动后,记得那几个端口在防火墙开放下。这样我们的离线服务器上的下载程序就部署好了。

接下来我们需要部署UI。

目前流行的UI方案是 AriaNg。这是个纯静态的网页,我使用的是基于 AriaNg 开发的 Chrome 扩展 => https://chrome.google.com/webstore/detail/aria2-for-chrome/mpkodccbngfoacfalldjimigbofkhgjn

安装好以后,打开扩展的选项进行 RPC 节点的配置,即刚才我们在服务器上搭建的下载服务。

image.png

配置好,点击 save 后,回到主界面的 Aria2状态 标签页下,就能看到自己处于已连接状态。

image.png

剩下的使用,就跟传统下载软件一模一样了。

到此,我们就有了一台离线下载服务器,需要下载什么东西,直接通过 AriaNg 添加下载任务到远端服务器即可。

下载好以后,可以选择在远端服务器直接打开,也可以选择拖回本地使用。

注意,远端服务器的选择,尽量选择带宽高,不限流量,且硬盘大的主机。可以访问下面的网站,获取好用不贵的 VPS。


好用不贵的VPS推荐

https://1hour.win


ET碎碎念,每周更新,欢迎订阅,点赞,转发!


感谢你的阅读,我是中文区见证人之一,欢迎通过 AuthSteem 来给我投票,或者打开 https://steemitwallet.com/~witnesses 页面,输入 ety001 进行投票。

2.gif

中文区的见证人目前有:
支持一下他们(按字母顺序),一人可以有30票


Thank you for reading. I'm a witness. I would really appreciate your witness vote! You can vote by SteemLogin. Or open https://steemitwallet.com/~witnesses page, input ety001 to vote.

2.gif

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63792.82
ETH 2563.50
USDT 1.00
SBD 2.66