Open-source NGROk

Ngrok

Suraj Panker
4 min readApr 5, 2020

--

let’s understand open source Ngrok. First, we have to understand what is Webhook, let’s go to the beautiful tech journey.

WebHooks: Webhooks are a way that apps can send an automated message to other applications. For example when someone pays you with the help of any payment app so how that app tells your accounting app. How Twilio routes phone calls to your number many more.

The general term “Open source” refers to something that can be modified because of its design publicly accessible means allows to end-user and developer not only to see source code but modify it as well. It is developed by GitHub.

What is Ngrok:-

It is multiplatform tunneling, reverse proxy software that establishes a secure tunnel from a public endpoint such as the internet to locally running network service while capturing all traffic for detailed inspection and reply. (Tunneling is a protocol that allows for the secure movement of data from one network to another).

Ngrok is a cross-platform application that enables developers to expose a local development server to the Internet with minimal effort. The software makes your locally-hosted web server appear to be hosted on a subdomain of ngrok.com, meaning that no public IP or domain name on the local machine is needed. Similar functionality can be achieved with Reverse SSH Tunneling, but this requires more setup as well as hosting of your remote server.

Ngrok can bypass NAT Mapping and firewall restrictions by creating a long-lived TCP tunnel from a randomly generated subdomain on ngrok.com (e.g. 3gf892ks.ngrok.com) to the local machine. After specifying the port that your web server listens on, the ngrok client program initiates a secure connection to the ngrok server and then anyone can make requests to your local server with the unique ngrok tunnel address. The ngrok developer’s guide contains more detailed information on how it works.

Ngrok can bypass NAT Mapping and firewall restriction by creating a long-lived TCP tunnel from a randomly generated subdomain on ngrok.com to local machine. After specifying the port that your webserver listens on, the ngrok client program connects to the ngrok server and then anyone can request your local server with a unique ngrok tunnel address.

There are many tunnel servers available around the world and locations include the US (Ohio), Europe (Frankfurt), Asia (Singapore), and Australia (Sydney). Alternatively, the ngrok server software can be self-hosted on a VPS or dedicated server.

One most important feature of ngrok is the ability to track and reply to HTTP requests via ngrok’s web console (accessible on http://127.0.0.1:4040/). The reply functionality is highly useful when testing API calls or webhooks as one can easily inspect all header content and request or response data in one place via the console UI.

Real-time Ngrok Usage in Vmoksha (A Case Study)(According to MR. About Uday Kiran)

After using Ngrok, MR. Uday Kiran had addressed all the requirements. Here is the following of how he had used the features of ngrok In his scenario he used ngrok in windows.

As this is a small 9MB executable(.exe) tool we can be generally executed with Ngrok command followed by the port no which has to be exposed as follows,

This gives a random subdomain on Ngrok.com and it’ll be accessible over both HTTP and HTTPS (Secure).

Running Multiple Tunnels Simultaneously:

We are using an extensive feature of Ngrok i.e., we can run multiple tunnels simultaneously and a few tunnel configuration is shown in the following YML configuration file.

Sample XML code for running multiple tunnels simultaneously (.yml file)

We can start all four tunnels simultaneously by using Ngrok start command followed by the names of the tunnels we want to start:

The Output Terminal will look something like this:

Request inspection with the Web Interface:

Web Interface is accessible on http://127.0.0.1:4040 using which we can inspect all the http traffic requests over the tunnel. We can also replay them to make the debugging quicker and easier.

Sample Web Interface for HTTP Traffic Inspection:

Architecture after Ngrok deployment

References:

  1. https://twilio-cms-prod.s3.amazonaws.com/images/ngrok.width-808.png.
  2. https://zapier.com/blog/what-are-webhooks/.

3. https://www.pubnub.com/learn/glossary/what-is-ngrok/.

4. https://vmokshagroup.com/author/alagappan-narayanan/.

--

--