首先获取ngrok,从自己的服务器生成下载。
cd /home/pi/
wget muumlover.com:8080/bin/linux_arm/ngrok
生成ngrok配置ngrok.cfg
touch ngrok.cfg
vim ngrok.cfg
server_addr: muumlover.com:4443
trust_host_root_certs: false
配置ngrok客户端启动
cd /etc/init.d/
touch ngrok
chmod +755 ngrok
vim ngrok
编辑启动脚本
#!/bin/bash
### BEGIN INIT INFO
# Provides: ngrok
# Required-Start:
# Required-Stop:
# default-Start: 2 3 4 5
# default-Stop: 0 1 6
# Short-Description: Start/Stop ngrok server
### END INIT INFO
do_start()
{
cd /home/pi/
nohup sudo ./ngrok -config ngrok.cfg -subdomain print 5000 &
nohup sudo ./ngrok -config ngrok.cfg -subdomain wechat 8000 &
nohup sudo ./ngrok -config ngrok.cfg -subdomain paper 8080 &
}
do_stop()
{
ps -ef | grep ngrok | awk '{print $2}' | xargs kill -9
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
do_start
;;
*)
;;
esac
开启自启动服务
apt-get install chkconfig -y
sudo chkconfing ngrok on
chkconfing ngrok