# ngrok

In 
Published 2022-12-03

This tutorial explains to you how to use the ngrok tool.

ngrok is a simplified API-first ingress-as-a-service that adds connectivity, security, and observability to your apps with no code changes.

In order to use ngrok, we need to create an account on https://ngrok.com first and to install ngrok on our machine.

# Create ngrok account

Go to ngrok.com and click on "Sign up" button. You will see something like this:

Enter a name, an e-mail address, and a password. Accept the terms of service, pass the reCAPTCHA check and click on "Sign Up" button.

You will receive an email at that address for let ngrok.com verify your address. For this you need to click on that link.

After that you can log without warning to your account:

# ngrok installation on Windows

There are 2 ways we can install ngrok on our machine:

  • download the software from the ngrok.com and unzip the executable from the download;
  • install ngrok via Chocolatey

As I have Chocolatey, I will use Chocolatey for this tutorial. So I will run the following command in powershell:

choco install ngrok

# ngrok usage

In order to use ngrok, we need to configure it. This is done by running the following command:

ngrok config add-authtoken <token>

Your token could be found at https://dashboard.ngrok.com/get-started/your-authtoken.

Now we can use ngrok.

In my case I have the following situation:

  • An application is running on a Linux virtual machine on 192.168.72.132, port 8080.
  • This IP/port is accessible from the Windows machine which host the Linux VM
  • The Windows machine is connected to the Internet

For letting anyone from Internet accessing our http://192.168.72.132:8080, we need to run the following command:

ngrok http 192.168.72.132:8080

After that we can see the following image:

Now we can access from the Internet our local application by accessing https://8857-95-76-244-219.eu.ngrok.io.

In order to force an unsecured connection you can run the following command:

ngrok http --scheme=http 192.168.72.132:8080