1、为什么要使用ngrok?
作为一个Web开发者,我们有时候会需要临时地将一个本地的Web网站部署到外网,以供它人体验评价或协助调试等等,通常我们会这么做:
1. 找到一台运行于外网的Web服务器
2. 服务器上有网站所需要的环境,否则自行搭建
3. 将网站部署到服务器上
4. 调试结束后,再将网站从服务器上删除
2、有了ngrok之后,世界是如此的美好
1. 首先注册并下载ngrok,得到一串授权码
2. 运行命令ngrok -authtoken 你的授权码 80,80是你本地Web服务的端口,而之后ngrok会记住你的授权码,直接ngrok 80就OK了
3. 你会得到一串网址,通过这个网址就可以访问你本地的Web服务了
3、如何使用呢?
Step 1: Download ngrok
下载地址 https://ngrok.com/
Step 2: Unzip it
On Linux or OSX you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip.
$ unzip /path/to/ngrok.zip
Step 3: Run it!
Read the Usage Guide for documentation on how to use ngrok. Try it out by running it from the command line:
$ ./ngrok -help
下面是我自己启动的服务
我再3000端口启动本地的服务:
本文介绍了一种利用ngrok工具轻松实现本地Web服务公网访问的方法,通过简单的步骤即可让他人远程访问和调试你的本地网站,无需复杂的服务器部署过程。
322





