Muvi Blogs

Beyond The Buzz- Latest Insights From Muvi

Please wait while we enable your Account

0%

Contacting Amazon Web Services
Deploying Cloud Servers, Storage, Transcoding & Database Servers
Deploying Global CDN
Deploying Firewall & Enabling Security Measures
Deploying the CMS & Admin Module
Deploying Website, Mobile & TV Apps framework
Creating your FTP account
Finishing up all the modules
Preparing for launch

How To Create Your Own ngrok? 15 December 2022

How To Create Your Own ngrok

 

While developing web applications, you must have experienced issues with development and testing servers, especially while accessing your local systems over the internet, right? we are guessing the answer would be yes, as almost all of us have faced the issue multiple times. Many developers remain concerned over the security of their applications in this phase, while many others get hiccups while testing multiple IoT devices. But have you ever searched for a reliable application that will help resolve all these issues? Well, we have got you a solution today! 

If you want, you can try ngrok! It is one of the easiest programmable network applications out there. And if you are not willing to do so, well…we will tell you how to create your own ngrok-like application from scratch, in this blog! So, keep reading and start creating your own ngrok! 

 

What is ngrok?

ngrok is a very popular application that allows our system to be accessed via the internet. We can test mobile apps by connecting to our local system or build demo websites, notification URLs, etc. There are a lot of alternatives but we have found this one to be the simplest and quickest to get started. 

Technically speaking, it is a set of globally-distributed network proxies that front your web applications running in any cloud, local, private network, or even your machine setup. ngrok claims that while doing so, you don’t need to change your code at all. It simply puts the local host on the internet and lets you develop consumer webhooks, demo websites, and much more!

Hence, it has the potential to completely eliminate all the issues faced while accessing local systems over the internet. In fact, you don’t even have to change any of your existing network settings and if you want, you do not need to even connect to a VPN!  

The multiple applications of ngrok make it one of the most desirable applications for many developers. But do you know, creating a ngrok-like application for your own is not that difficult! But before we just into that section, we must properly understand how ngrok actually works!

 

How does ngrok work under the hood?

ngrok uses ssh tunneling where an ssh connection is made between the local system and a remote system through port forwarding. There are 2 types of port forwarding i.e. local port forwarding and remote port forwarding.

 

local port forwarding concept How To Create Your Own ngrok
Credit – iximiuz.com
remote port forwarding concept How To Create Your Own ngrok
Credit – iximiuz.com

 

Here, we can clearly see that ngrok uses the remote port forwarding concept. 

The command

> ngrok http 80

internally runs the ssh tunneling command

> ssh -R localhost:remote_port:localhost:80 [user@]remote_addr

Here the left-hand side localhost:remote_port refers to the server, and remote_port can be any port number that is not used.

Now that we have got a basic understanding of how ngrok actually works, let’s dive into creating our own ngrok!

 

Create your own ngrok

If you have a server and can ssh into it, then you can easily create a ngrok-like application for yourself. Then, you don’t need to use any third-party ssh tunneling application like ngrok anymore.

Here, we are using an example that is based on an EC2 instance, that has a web server apache2 installed. Our purpose is that when someone hits the EC2 instance public IP in the browser it will serve from my localhost.

 

Steps to follow:

1. First, we created an EC2 instance from the AWS console. We logged into the ec2 instance using the below command:

Here your_key.pem is my key file and is the public IP of the ec2 instance xxx.xxx.xxx.xxx. 

2. Next, we installed the apache2 server and enabled its reverse proxy modules.

Here, the reverse proxy forwards any request to 80 to port 8080. We are using this reverse proxy here because port 80 is already used by the web server and it cannot be used for ssh tunneling. So, if we run the URL now in the browser then it will not work as there is no application listening to 8080.

3. Finally, we established the ssh remote tunneling

> ssh -R localhost:8080:localhost:80 ubuntu@xxx.xxx.xxx.xxx -we your_key.pem

As you can see, now we can browse from the local system.

 

Should we use our own tunneling?

So, one question must be arising in your mind right now – why should we use our own tunneling, when alternatives like ngrok are already available?

The answer to this question is subjective. If your intention is to use it for a quick demo or testing purpose, then using your own architecture is not desirable, as ngrok will prove to be a much simpler process. 

However, if you are working on an important project, and already have a server and a static IP or domain name, and do not want to open up your local system to any unknown server then you can definitely go for your own tunneling. It will make the process much more secure and efficient. The choice is yours! 

 

Author Credit:

Before we say goodbye to you all, we must give credit where it’s due – this blog was drafted by Suraj Kumar Mohapatra, software development manager of our player pod, who has brainchild the entire procedure. Further, the blog was edited and fine-tuned by Debarpita Banerjee. We hope you enjoyed reading it! 

 

Start your OTT Platform

Don't forget to share this post!


Debarpita Banerjee
Debarpita works as a content writer with Muvi. She has worked across industries like EdTech, eLearning, AR-VR and Metaverse. She is a team player and believes in teamwork to help achieve a collective common goal. She also believes in delivering content that can add some value to the users and prove to be beneficial in taking our brand to the next level.

Latest Posts

Try Muvi One free for 14 days

No Credit Card Required

.muvi.com
Your website will be at https://yourname.muvi.com, you can change this later.

Related Blogs
How to Develop Your Own LG TV WebOS App Without Coding?

How to Develop Your Own LG TV WebOS App Without Coding?

  In 2021, LG TVs held an 18.9% share of the global television market. We don’t need to tell you...

20 January 2023
OTT Business Model 2023 - How OTT Platforms Make Money?

OTT Business Model 2023 - How OTT Platforms Make Money?

  Are you eager to know about How OTT platforms make money? In this blog, we will discuss how OTT...

18 January 2023
What Are The Different Types of Cyber Attacks on OTT Platforms?

What Are The Different Types of Cyber Attacks on OTT Platforms?

  Cybercrimes were predicted to inflict damages amounting to US$ 6 trillion in 2021. In that scenario, cybercrime would have...

17 January 2023
A Complete Guide to Growing Your Video Membership Site

A Complete Guide to Growing Your Video Membership Site

  The demand for video membership sites has grown exponentially over the past few years making it a highly profitable...

17 January 2023
[New Tutorial] Screen Share your Roku Device on your Laptop for Online Meetings [Zoom / GMeet]

[New Tutorial] Screen Share your Roku Device on your Laptop for Online Meetings [Zoom / GMeet]

  If you are a Roku App developer, then you must have faced the Roku TV Screen sharing issue multiple...

13 January 2023

Try Muvi One
Free for 14 days

Launch your Multi-Screen Streaming Service
Instantly
START FREE
close-link