Site icon JuanBoteroTech

How to use Ngrok

Sometimes we need to expose over the web the projects  that we are building, just to show to the customer or enable the calls to our apps via webhooks, That is the purpouse of Ngrok.

Before all, I want to explain something, that is the Proxy concept.

What is a proxy?

A Proxy is an internet server that works as a gateway between two points on internet; for example, on a corporate network, when the users browse the web, all the data pass through a proxy, so, the proxy capture the petition, goes to the web page  and then decides to filter and deny the access to malicious pages (like gore pages or phising).

For the user, the proxy is transparent, he or she can work without interruptions and doesn’t need to know the configuration of the proxy.

Besides that, a Proxy server can operates as a cache server, in the same way as filtering the web pages to users, it can be a  web cache, so, the response and render of web pages will be faster.

Knowing already what is a Proxy, let me tell you what is Ngrok.

What is Ngrok?

Ngrok is a reversed proxy that you can use to publish web services that run on your computer or your private cloud.

That means, that when you publish your web service through Ngrok, many people (or other apps) can access to it and use it like using Ngrok, and it will be redirected to the server in your computer.

How Ngrok works: https://ngrok.com/

How to use Ngrok

To use Ngrok, you need to install it, this is how you how to install on Linux

Install Ngrok in Linux

Download the file.

$ wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz

Uncompress the tgz file in /usr/local/bin/ folder, so, ngrok will be available to execute.

 sudo tar xvzf ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin

You can also install Ngrok via APT:

curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo “deb https://ngrok-agent.s3.amazonaws.com buster main” | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok

Now, test Ngrok:

$ ngrok -v

ngrok version 3.0.5

Create an account in Ngrok

First, you must create a Ngrok account and add the token to your terminal, thus, Ngrok will enable your service.

To create a Ngrok account, you can use your GitHub account or your Google Account.

Sing Up for a Ngrok account

When the Ngrok dashboard loads, go to the second step and copy the command to connect your Ngrok account in your terminal:

$ ngrok config add-authtoken your-auth-token

Create a tunnel to publish your service

Once you have Ngrok installed you can publish your service or web app, it can be a Flask project that you build or a conventional web server that runs over 80 port, the basic usage is pretty straighforward.

$ ngrok <protocol> <port>

Lets suppose you need to publish a Laravel app that is running with an Apache web server andyou need to show the app to your customer, what you have to do is this:

$ ngrok http 80

Then you will get the ngrok session information with the url assigned to your service and the the summary of the connections.

At this point you can give the Ngrok url to your customer, and he or she will see your project and give you some feedback.

Your customer will see a message that indicated that he or she will visit a site through ngrok.com, there’s no problem with that, just click on the blue button and the web page will be  displayed.

My web server through ngrok.com

How much cost Ngrok

You can start using Ngrok for free if you just need it for causal use, even if you are looking a more professional features like use it with a custom doamin or load balancing, consider the plans with payment to do this.

The paid licenses start from USD 20 to USD 65 and can be used with your team and your organization.

Exit mobile version