The way to run Ngrok in the background is described in the previous article. And we use Ngrok a lot of time to want to boot up on their own, the method is as follows:
One, create a new startup script in the Ngrok program directory, for example:
Path=/usr/appdata/ngrok
nohup $path/ngrok-config $path/ngrok.cfg start http ssh
Path is the current directory
Start script to write background startup script, after the startup project according to their own needs to write
Second, make the Ngrok program into a system service
Create a new service item (Ngrok) under the/ETC/RC.D/INIT.D directory, as follows:
#!/bin/sh
#chkconfig: 2345
#description: Ngrok ngrok_path=/usr/appdata/ngrok case
"$"
in Start)
echo "Start Ngrok service ..."
SH ${ngrok_path}/start.sh
;;
*)
exit 1
;;
Esac
Assigning permissions to the file 755
chmod 755 Ngrok
Third, registration Ngrok service from start
Chkconfig--add Ngrok
Test whether the service can start successfully
Service Ngrok Start
Check for self-initiated services
Chkconfig
OK, restart the server to verify it. Success
If you have a top-level domain name, you want to access the local project through your domain name, then first resolve your top-level domain name to the IP of the Ngrok server (the domain name needs to be recorded OH), and then perform Ngrok-config=ngrok.cfg-hostname xxx.xxx.xxx (Xxx.xxx.xxx is your custom top-level domain)