在ac68u上部署aria2

好好的 aria2 + frp 突然就不能用了,经过检查发现路由器挂载的移动硬盘数据全无,重新安装并记录如下:

系统:merlin 380.65_2

搭配 500G 移动硬盘

通过 ssh 链接到路由器。格式化移动硬盘至两个分区,方法见此链接。格式化后如果只挂在一个分区,重启路由即可。

ssh 到路由器执行 entware-setup.sh 安装 opkg,选择硬盘分区至 entware 下。

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
opkg install aria2
# 修改配置
vi /opt/etc/aria2.conf
#################### aria2 conf begin
# Basic Options
dir=/tmp/mnt/data/downloads
input-file=/opt/var/aria2/session.dat
log=/opt/var/log/aria2.log
max-concurrent-downloads=3
check-integrity=true
continue=true
# BitTorrent/Metalink Options
bt-enable-lpd=true
bt-max-open-files=16
bt-max-peers=8
dht-file-path=/opt/var/aria2/dht.dat
dht-file-path6=/opt/var/aria2/dht6.dat
dht-listen-port=6801
#enable-dht6=true
listen-port=6801
max-overall-upload-limit=2M
seed-ratio=0
# RPC Options
enable-rpc=true
rpc-allow-origin-all=true
#rpc-certificate=/opt/var/aria2/aria2.pfx
rpc-listen-all=true
rpc-listen-port=6800
rpc-secret=token
#rpc-secure=true
################### aria2 end
# 启动 aria2c
/jffs/scripts/services-stop
/jffs/scripts/services-start

安装 nginx + webui-aria2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
opkg install nginx
cd /tmp/mnt/entware/entware/share/nginx/html
opkg install git-http
# 不要用 ssh 协议的地址,会报无权限错,原因未查。
git clone https://github.com/ziahamza/webui-aria2.git
#修改 nginx 的配置文件
vi /opt/etc/nginx/nginx.conf
# 只需修改 server 的 location
server {
listen 8080;
server_name localhost;

#charset koi8-r;

#access_log /opt/var/log/nginx/host.access.log;

location / {
root /opt/share/nginx/html/webui-aria2/;
index index.html index.htm;
}
#启动 nginx
/jffs/scripts/services-stop
/jffs/scripts/services-start
#在浏览器输入路由器地址和端口号即可访问:http://192.168.0.1:8080

部署 vps 上的 frps,配置如下:

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
# [common] is integral section
[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
bind_addr = 0.0.0.0
bind_port = 7000
# if you want to support virtual host, you must set the http port for listening (optional)
vhost_http_port = 8000
# console or real logFile path like ./frps.log
log_file = /var/log/frps.log
# debug, info, warn, error
log_level = info
log_max_days = 3
# authentication_timeout means the timeout interval (seconds) when the frpc connects frps
# if authentication_timeout is zero, the time is not verified, default is 900s
authentication_timeout = 900
[aria2]
# if type equals http, vhost_http_port must be set
type = http
auth_token = yourtoken
# if proxy type equals http, custom_domains must be set separated by commas
custom_domains = aria2.yourdomain.com
[a]
# if type equals http, vhost_http_port must be set
type = http
auth_token = yourtoken
# if proxy type equals http, custom_domains must be set separated by commas
custom_domains = a.yourdomain.com

下载 frp 的 arm 版本到本地
https://github.com/fatedier/frp/releases/download/v0.9.3/frp_0.9.3_linux_arm.tar.gz
解压后删除 frps 相关的文件和 frpc_min.ini

编辑 frpc.ini:

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
# [common] is integral section
[common]
# A literal address or host name for IPv6 must be enclosed
# in square brackets, as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80"
server_addr = your_ip_address
server_port = 7000
# if you want to connect frps by http proxy, you can set http_proxy here or in global environment variables
# http_proxy = http://user:pwd@192.168.1.128:8080
# console or real logFile path like ./frpc.log
log_file = /opt/var/log/frpc.log
# debug, info, warn, error
log_level = error
log_max_days = 3
# for authentication
auth_token = yourtoken
# heartbeat configure, it's not recommended to modify the default value
# the default value of heartbeat_interval is 10 and heartbeat_timeout is 30
# heartbeat_interval = 10
# heartbeat_timeout = 30
[dns]
type = udp
local_ip = 114.114.114.114
local_port = 53
# Resolve your domain names to [server_addr] so you can use http://web01.yourdomain.com to browse web01 and http://web02.yourdomain.com to browse web02, the domains are set in frps.ini
[aria2]
type = http
local_ip = 127.0.0.1
local_port = 8080
use_gzip = true
# http username and password are safety certification for http protocol
# if not set, you can access this custom_domains without certification
http_user = name
http_pwd = password
[a]
type = http
local_ip = 127.0.0.1
local_port = 6800
use_gzip = true

部署到路由器:

把 frpc 放到 /opt/bin/
把 frpc.ini 放到 /opt/etc
启动测试 frpc

1
/opt/bin/frpc -c /opt/etc/frpc.ini

在浏览器中输入 http://aria2.yourdomain.com:8000 会弹出输入账号和密码,输入 frpc.ini 中配置好的账号密码即可看到部署到路由器上的 Aria2WebUI, 因为没有配置 aria2 所以会报错,在 WebUI 上找到 设置–>连接设置 如图:

提示连接成功说明以上操作均无问题 ctrl+c 关闭frpc。

下面是设置frpc自启动并且定时重新执行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
vi /jffs/scripts/services-start
#在文件最后换行添加以下命令
nohup /opt/bin/frpc -c /opt/etc/frpc.ini >/dev/null 2>&1 &
cru a frpc_cron "25 7,12,17 * * * /opt/bin/frpc -c /opt/etc/frpc.ini"
# 每天的 7:25,12:25, 17:25 定时执行启动
vi /jffs/scripts/services-stop
#在文件最后换行添加
cru d frpc_cron
/jffs/scripts/services-stop
/jffs/scripts/services-start
#查看是否正确执行
ps | grep frpc
#上面的命令执行后可以用此命令杀死 frpc 进程
kill -9 pid_number