Sunny-Ngrok内网穿透
1.解决问题
测试外部接口回调,内网无法测试问题
2.使用方法
2.1平台注册(外网访问)
申请免费隧道,获取隧道id
2.2下载(外网访问)
https://www.ngrok.cc/download.html
2.3安装
sudo mv sunny /usr/local/bin/sunny
sudo chmod +x /usr/local/bin/sunny
2.4编写启动脚本
sudo vim /etc/init.d/sunny
将上面获取到的id替换脚本中的id
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: ngrok.cc
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: autostartup of ngrok for Linux
### END INIT INFO
NAME=sunny
DAEMON=/usr/local/bin/$NAME
PIDFILE=/var/run/$NAME.pid
[ -x "$DAEMON" ] || exit 0
case "$1" in
start)
if [ -f $PIDFILE ]; then
echo "$NAME already running..."
echo -e "\033[1;35mStart Fail\033[0m"
else
echo "Starting $NAME..."
start-stop-daemon -S -p $PIDFILE -m -b -o -q -x $DAEMON -- clientid 隧道id || return 2
echo -e "\033[1;32mStart Success\033[0m"
fi
;;
stop)
echo "Stoping $NAME..."
start-stop-daemon -K -p $PIDFILE -s TERM -o -q || return 2
rm -rf $PIDFILE
echo -e "\033[1;32mStop Success\033[0m"
;;
restart)
$0 stop && sleep 2 && $0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
2.5给脚本赋权限
sudo chmod 755 /etc/init.d/sunny
2.6启动与停止
sudo /etc/init.d/sunny start #启动
sudo /etc/init.d/sunny stop #停止
sudo /etc/init.d/sunny restart #重启