缘起
由于使用了一个没有自带FRP的K3 OPENWRT固件,因此需要手动安装。
开搞
下载FRP
下载地址https://github.com/fatedier/frp/releases,选择frp_0.31.2_linux_arm.tar.gz,下载完成之后再k3上使用tar命令解压。
tar xzvf frp_0.31.2_linux_arm.tar.gz
然后把所有的没用的frps相关文件删除。
配置FRP
# [common] is integral section
[common]
server_addr = frp.aiuyo.com
server_port = 7000
log_file = /root/frp/frpc.log
# trace, debug, info, warn, error
log_level = info
log_max_days = 3
# disable log colors when log_file is console, default is false
disable_log_color = false
# for authentication
token = www.aiuyo.com
# set admin address for control frpc's action by http api such as reload
admin_addr = 192.168.2.1
admin_port = 7400
admin_user = admin
admin_pwd = admin
# Admin assets directory. By default, these assets are bundled with frpc.
# assets_dir = ./static
# connections will be established in advance, default value is zero
pool_count = 5
# if tcp stream multiplexing is used, default is true, it must be same with frps
tcp_mux = true
# your proxy name will be changed to {user}.{proxy}
user = rt
# decide if exit program when first login failed, otherwise continuous relogin to frps
# default is true
login_fail_exit = true
# communication protocol used to connect to server
# now it supports tcp and kcp and websocket, default is tcp
protocol = tcp
# if tls_enable is true, frpc will connect frps by tls
tls_enable = true
# 'ssh' is the unique proxy name
# if user in [common] section is not empty, it will be changed to {user}.{proxy} such as 'your_name.ssh'
[ssh]
# tcp | udp | http | https | stcp | xtcp, default is tcp
type = tcp
local_ip = 127.0.0.1
local_port = 22
use_encryption = false
# if true, message will be compressed
use_compression = false
# remote port listen by frps
remote_port = 5122
[blog]
type = http
local_ip = 192.168.2.8
local_port = 80
use_encryption = true
use_compression = true
custom_domains = www.wangxianfeng.cn,wangxianfeng.cn
[router]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = true
use_compression = true
#subdomain = web01
custom_domains = router.aiuyo.com
编写启停脚本
启动脚本(startfrp.sh)
/root/frp/frpc -c /root/frp/frpc.ini &
停止脚本(stopfrp.sh)
num=0
ps -w | grep "frpc" | grep -v grep | awk '{print $1}'|while read frpcpid
do
echo "frpc process exist!:" $frpcpid
num=`expr $num + 1`
echo $num > /tmp/$$.list
kill $frpcpid
done
num=`cat /tmp/$$.list`
if [ $num -eq "0" ]; then
echo "There're no frpc process running!"
else
echo "$num frpc process killed!"
fi
shell编程使用管道的while循环无法将变量的值传出来,解决方法
文章评论