我让ngrok在我远程访问的服务器上运行。
我从显而易见的ngrok.exe http 80开始。问题是,当我在那个特定的服务器上注销时,ngrok将关闭,我将失去我的隧道。有没有一种方法可以让ngrok隧道保持运行,即使我已经注销机器?我明白,如果机器关闭了,我就不能做任何事情来保持隧道运行,这是显而易见的。有什么想法吗?
提前谢谢。
发布于 2018-06-12 11:10:13
正如您所说的,如果机器关闭,进程将无法保持运行。有许多方法可以做到这一点。在这些方法中,我假设您已经有了以下配置文件:
config.yml
authtoken: <your-auth-token>
tunnels:
default:
proto: http
addr: 80Ngrok Link (Windows/Mac OS/Linux,商用版)
使用ngrok link,只需运行以下命令:
ngrok service install -config /path/to/your/config.yml
ngrok service start然后,您应该能够像管理在给定操作系统上运行的任何其他服务一样管理ngrok。
Nohup (Maco OS/Linux)
nohup命令通常默认安装在mac os和linux上。要运行该命令,请执行以下操作:
nohup ngrok start --all --config="path/to/config.yml" &在屏幕中运行也应该在这里达到相同的效果。
创建Windows服务(Windows)
要创建服务,您需要下载一个用于从非服务可执行文件创建服务的程序。在这里,我将介绍如何使用NSSM (Non-Sucking Service Manager)来做到这一点。
nssm.exe安装ngrok
启动--现在可以从服务管理器管理所有--config="C:\path\to\my\config.yml"
sc启动ngrok
创建systemd服务(仅限Linux- systemd )
需要root用户。
将
ngrok.service
Unit Description=Ngrok After=network.service type=simple User= WorkingDirectory=/home/ ExecStart=/usr/bin/ngrok start --all --config="/path/ to /config.yml“Restart=on-failure Install ExecStart运行以下命令以启动并启用该服务
systemctl启用ngrok.service && systemctl启动ngrok.service
资料来源:
https://ngrok.com/docs/ngrok-link#service
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
https://stackoverflow.com/questions/50681671
复制相似问题