基于 Aria2 + AriaNg + Nginx 搭建离线下载平台,支持 BT/PT 下载。
参考链接:
systemd
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [Unit] Description=Aria2 Download Manager After=network.target
[Service] Type=simple User=zhuyuqinlan Group=zhuyuqinlan ExecStart=/usr/bin/aria2c --conf-path=/etc/aria2/aria2.conf Restart=on-failure RestartSec=5
[Install] WantedBy=multi-user.target
|
aria2.conf
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
| input-file=/home/zhuyuqinlan/.aria2/aria2.session save-session=/home/zhuyuqinlan/.aria2/aria2.session
dir=/home/zhuyuqinlan/docker/filebrowser/data/aria2 continue=true
max-connection-per-server=5 min-split-size=10M
enable-rpc=true rpc-allow-origin-all=true rpc-listen-all=true rpc-secret=zhuyuqin520.com
listen-port=51413 enable-dht=false enable-peer-exchange=false peer-id-prefix=-TR2770- user-agent=Transmission/2.77 seed-ratio=0 bt-seed-unverified=true bt-save-metadata=true all-proxy=http://127.0.0.1:20172
|
完整配置项说明请参考 aria2 官方文档。
update_aria2_trackers.sh
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
| #!/usr/bin/env bash set -euo pipefail
RPC="http://127.0.0.1:6800/jsonrpc" TOKEN="zhuyuqin520.com" URL="${1:-https://bt.me88.top/?q=%E7%94%B5%E4%BF%A1}" MAX="${2:-100}"
TMP_HTML=$(mktemp) TMP_TRACKERS=$(mktemp)
curl -fsSL "$URL" -o "$TMP_HTML"
perl -nle 'while(/<td[^>]*\bnodetype=["'"'"']url["'"'"'][^>]*>([^<]+)<\/td>/gi){ print $1 }' "$TMP_HTML" \ | tr -d '\r' \ | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' \ | awk '!seen[$0]++{print}' \ | head -n "$MAX" \ > "$TMP_TRACKERS"
if [ ! -s "$TMP_TRACKERS" ]; then echo "未提取到任何 tracker,退出" >&2 exit 1 fi
TRACKERS_CSV=$(paste -sd, - < "$TMP_TRACKERS") ESC_TRACKERS=$(printf '%s' "$TRACKERS_CSV" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')
JSON=$(printf '{"jsonrpc":"2.0","method":"aria2.changeGlobalOption","id":"1","params":["token:%s",{"bt-tracker":"%s"}]}' "$TOKEN" "$ESC_TRACKERS") RESP=$(curl -sS -H "Content-Type: application/json" -d "$JSON" "$RPC" || true)
echo "aria2 RPC 返回:" echo "$RESP" echo echo "已更新 bt-tracker(前 500 字):" printf '%s\n' "$TRACKERS_CSV" | cut -c1-500
rm -f "$TMP_HTML" "$TMP_TRACKERS"
|
nginx
nginx.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| worker_processes 1;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65;
include conf.d/*.conf; }
|
ariang.conf
1 2 3 4 5 6 7 8 9 10 11
| server { listen 8888; server_name localhost;
root /usr/share/nginx/html/ariang; index index.html;
location / { try_files $uri $uri/ /index.html; } }
|