对于任何开发人员来说,最大的挑战是测试他们编写的软件。当您为移动设备或与您不同的平台构建某些东西时,测试变得更加困难。大部分(Mostly)发展发生在地方一级;所有的 Web 服务器都在 localhost 上运行。只有您可以在将其部署到某个地方之前查看您的工作。输入ngrok ,这是一项适用于(ngrok)Windows的免费服务,它通过安全隧道将本地服务器公开给公共互联网。
什么是 ngrok 安全
什么是ngrok?如何使用 ngrok?ngrok 允许您通过安全隧道将防火墙(Firewalls)后面的本地服务器公开到公共互联网。该工具需要零配置,并带有内置的网络拦截器。
隧道已经流行多年了,大多数VPN(VPNs)也使用隧道的概念来让您不受限制地访问网站。同样,ngrok 在公共 Internet 和您的 localhost 服务器之间创建一个安全隧道。基本上(Basically),您可以使用单个命令通过互联网访问http://localhost:8080上运行的任何网站/web-app/web-service 。
ngrok 提供的大部分功能都可以免费使用。对于想要测试其应用程序的中级开发人员来说,免费软件的限制已经足够了。尽管 ngrok 也作为服务提供,但完全可以选择跳过该部分并直接下载该工具并开始使用。
如何使用 ngrok
您可以注册 ngrok,它是免费的。创建一个帐户可以让您从基于云的仪表板管理所有活动隧道。
如何将本地 Web 服务器公开到 Internet(How to expose your local web server to the internet)
创建到本地 Web 服务器或任何服务器的隧道非常简单。下载(Download)并解压 ngrok。现在打开一个CMD/PowerShell窗口并导航到解压缩内容所在的文件夹。
现在执行以下命令以创建到本地服务器的安全隧道。
./ngrok http 8080
其中 8080 是您的服务器正在侦听的端口。如果您不确定端口号,请转到默认端口号 80。
如果您想将此 ngrok 实例连接到您的帐户,则应在执行上述命令之前提供身份验证令牌。为此,请登录您的 ngrok 帐户。从那里获取您的身份验证令牌,然后在CMD窗口中执行以下命令。
./ngrok authtoken your_token_here
这只是一次性动作,不需要每次都重复。
创建隧道后,ngrok 将显示到您的服务器的公共URL 。公共URL是 ngrok.io 的子域,是随机生成的。您甚至可以创建持久且易于阅读的可自定义子域,但为此,您需要升级到付费计划。
我认为默认URL(URLs)足以测试您的应用程序。仅当您想要生产级和持久的东西时,才应考虑升级。
ngrok 拦截器
ngrok 还带有一个内置的拦截器,可以通过打开http://127.0.0.1:4040来打开。拦截器将让您查看所有传入的网络请求及其响应。当您正在调试某些东西或想要查看传入的请求时,拦截器非常方便。(Interceptor)在拦截器旁边,您可以找到状态选项卡。此选项卡可让您查看有关您的隧道的所有类型的信息。您可以查看一些统计信息,例如连接、连接持续时间、HTTP请求、服务器地址和协议。
使用免费计划,您一次只能创建一个隧道。如果您想同时运行多个隧道,请考虑升级。
ngrok 对开发人员和爱好者来说是一个有用的工具。它使您可以将现有的本地主机服务器转换为可以从任何地方访问的公共服务器。我是在一次黑客马拉松中被介绍给这个工具的。ngrok 在黑客马拉松、演示、演示、移动应用程序测试、webhook 集成以及所有你想在不实际部署的情况下运行应用程序的情况下非常有用。ngrok 是免费使用的,而且隧道超级容易创建,让您更专注于开发。单击此处(Click here)(Click here)下载 ngrok。
ngrok: Make your Local Servers public with Secure Tunnels
The biggest challenge for any developer is the testing of the software that they’ve written. And testing becomes more difficult when you are building something for mobіle or a platform different than yours. Mostly developmеnt occurs at the local level; all the web sеrvers are running on localhost. Only you can view your work before dеploying іt somewhere. Enter ngrok, a free service for Windows that exposes local servers to the public internet over secure tunnels.
What is ngrok security
What is ngrok? How to use ngrok? ngrok lets you expose local servers behind Firewalls, to the public internet over secure tunnels. The tool requires zero configuration and comes with an inbuilt network interceptor.
Tunneling has been prevalent for years now, most of the VPNs also use the concept of tunneling for giving you unrestricted access to websites. Similarly, ngrok creates a secure tunnel between the public internet and your localhost server. Basically, you can make any website/web-app/web-service running on http://localhost:8080 accessible via the internet with a single command.
Most of the features offered by ngrok are free to use. And freeware limits are good enough for an intermediate developer who is looking to test their application. Although ngrok is also offered as a service, it is totally optional to skip that part and directly download the tool and get going.
How to use ngrok
You can sign-up for ngrok, and it is free. Creating an account will let you manage all your active tunnels from a cloud-based dashboard.
How to expose your local web server to the internet
Creating a tunnel to your local web server or any server is very simple. Download and unzip ngrok. Now open a CMD/PowerShell window and navigate to the folder where the unzipped contents are.
Now execute the following command to create a secure tunnel to your local server.
./ngrok http 8080
Where 8080 is the port on which your server is listening. If you are not sure about the port number, go to the default port number that is 80.
If you want to connect this ngrok instance to your account, you should provide the authentication token before executing the above command. To do so, log in to your ngrok account. Obtain your auth token from there and then execute following command in a CMD window.
./ngrok authtoken your_token_here
This is just a one-time action and needs not to be repeated every time.
Once you’ve created a tunnel, ngrok will display the public URL to your server. The public URL is a subdomain of ngrok.io and is generated randomly. You can even create persistent and easy-to-read customizable subdomains, but for that, you need to upgrade to a paid plan.
I think the default URLs are good enough for testing your application. You should consider upgrading only if you want something production grade and persistent.
ngrok Interceptor
ngrok also comes with an inbuilt interceptor that can be opened by opening http://127.0.0.1:4040. The interceptor will let you view all the incoming network requests and their responses. Interceptor comes very handy when you are debugging something or want to view the incoming requests. Beside the interceptor, you can find the status tab. This tab would let you view all sort of information about your tunnel. You can view some stats like connections, connection durations, HTTP requests, server addresses, and protocols.
With the free plan, you can only create one tunnel at one time. Consider upgrading if you want to run more than one simultaneous tunnels.
ngrok is a useful tool for developers and enthusiasts. It lets you convert your existing localhost server to a public server that can be accessed from anywhere. I was introduced to this tool in a hackathon. And ngrok can be really very useful in hackathons, demos, presentations, mobile-app testing, webhook integrations and all those cases where you want to run your application without actually deploying it. ngrok is free to use, and the tunnels are super easy to create, which lets you focus more on development. Click here to download ngrok.