How to Test Local Websites or Apps on Internet Using Ngrok

Are you a website or mobile application developer, and want to expose your localhost server behind a NAT or firewall to the public Internet for testing purposes? In this tutorial, we will reveal how...

Spread the love

Are you a website or mobile application developer, and want to expose your localhost server behind a NAT or firewall to the public Internet for testing purposes? In this tutorial, we will reveal how to do this securely using ngrok.

Ngrok is a sensational, free open source and cross-platform reverse proxy server for exposing local servers behind NATs and firewalls to the public Internet over secure tunnels. It is a remarkable computer program that you can use to implement personal cloud services directly from home.

It essentially establishes secure tunnels to your localhost, thus enabling you to: run demos of web sites before actual deployment, testing mobile apps connected to your locally running backend and building web-hook consumers on your development machine.

Ngrok Features:

  • Easy install with zero run-time dependencies for any major platform and works fast.
  • Supports secure tunnels.
  • Captures and analyzes all traffic over the tunnel for later inspection and replay.
  • Allows you to do away with port forwarding in your router.
  • Enables implementing of HTTP authentication (password protection).
  • Uses TCP tunnels to expose networked service that do not use HTTP such as SSH.
  • Supports tunneling only HTTP or HTTPS with SSL/TLS certificates.
  • Supports multiple simultaneous tunnels.
  • Allows for replaying webhook requests.
  • Enables you to work with virtual-host sites.
  • It can be automated via an API plus many options in the paid plan.

Before using it, you need to have a web server installed or consider setting up a functional LAMP or LEMP stack, otherwise follows these guides to:

Install LAMP Stack on Linux:

  1. Installing LAMP (Linux, Apache, MariaDB, PHP/PhpMyAdmin) in RHEL/CentOS 7.0
  2. How to Install LAMP with PHP 7 and MariaDB 10 on Ubuntu 16.10

Install LEMP Stack on Linux:

  1. How to Install LEMP (Linux, Nginx, MariaDB, PHP-FPM) on Debian 9 Stretch
  2. How To Install Nginx, MariaDB 10, PHP 7 (LEMP Stack) in 16.10/16.04
  3. Install Latest Nginx, MariaDB and PHP on RHEL/CentOS 7/6 & Fedora 20-26

How to Install Ngrok in Linux

Ngrok is super easy to install, simple run the commands below to download and unzip the archive file which contains a single binary.

$ mkdir ngrok
$ cd ngrok/
$ wget -c
$ unzip
$ ls
Download Ngrok Tool

Download Ngrok Tool

Once you have the binary file, let’s create a basic index.html page in the web server’s (Apache) default document root for testing requests to the web server.

$ sudo vi /var/www/html/index.html

Add the following HTML content in the file.

<!DOCTYPE html>
<h1>This is a Dummy Site</h1>
<p>We are testing Ngrok reverse proxy server.</p>

Save the file and launch ngrok by specifying the http port 80 (if you have configured you web server to listen on another port, you need to use that port):

$ ngrok http 80

Once you start it, you should see an output similar to the one below in your terminal.

Launch Ngrok on Terminal

Launch Ngrok on Terminal

How to Inspect Traffic to Your Web Server Using Ngrok UI

Ngrok offers a simple web UI for you to inspect all of the HTTP traffic running over your tunnels in real-time.

Ngrok Web Interface

Ngrok Web Interface

From the output above, no requests have been made to the server yet. To get started, make a request to one of your tunnel using the URLs below. Other user will also use these addresses to access your site or app. OR 
Check Local Website Over Ngrok

Check Local Website Over Ngrok

Then check from the inspection UI to get all of the details of the request and response including the time, client IP address, duration, headers, request URI, request payload and the raw data.

Check Website Requests

Check Website Requests

For more information, see the Ngrok Homepage:

Ngrok is simply an amazing tool, it is by far the simplest yet powerful secure local tunnel solution you will find out there. You should consider creating a free ngrok account to get more bandwidth, but if you want even more advanced features, try upgrading to a paid account. Remember to share your thoughts about this piece of software, with us via the comment form below.

Facebook Comments

More Stuff

Weird horror movies and TV for Halloween you may have overlooked &... Apostle (2018) Consider celebrating Halloween this year by watching overlooked horror movies featuring teenage cannibals, ghosts, killer cults, evil p...
Apple Abandons the Mass Market, as the iPhone Turns Luxury Big companies attract big attention, and none quite as much as Apple. Its quarterly reports have become something of a collective soothsaying moment f...
5 Ways to Empty or Delete a Large File Content in Linux Occasionally, while dealing with files in Linux terminal, you may want to clear the content of a file without necessarily opening it using any Linux c...
Learn The Basics of How Linux I/O (Input/Output) Redirection Works One of the most important and interesting topics under Linux administration is I/O redirection. This feature of the command line enables you to redire...
Spread the love

Posted by News Monkey