(Tutorial) How to expose localhost to the internet. (by Abhimanyu Das)

 Sometimes, we found a situation due to multiple reasons, where we need to expose our local server to internet, maybe we need to show our website to a client and doesn't have enough time for deploying, others, we need to test it out a webhook from a third service and we don't want to create a new deployment just for testing purpose.

So, let's go for it.


ngrok

There services that offer you to set up a tunnel between their servers and your local machine. There are several of them, nevertheless, my recommendation is ngrok.

It has a freemium model, it fits the most basic requirements.

How it works

We download and run a program(ngrok), specifying which port is our local server listening to. ngrok will connect to their external cloud service, creating a public endpoint redirecting all the traffic from it to your server. That's it, simple.

1. Download and setup

2. Download it from official site

3. Unzip /path/to/ngrok.zip into any folder

4. Start an HTTP tunnel in any port you want. Let's do it on 80


That's it. We just need to run our web server in port 80 and starting to receive traffic.

If you want to test it out. You may send a request using curl to our public ngrok domain, http://82330e5b.ngrok.io or just open it in a browser. Additionally, ngrok allows https connections, this is a great feature when we are testing external services needing a secure connection.


by:- Abhimanyu Das

Comments

Popular Posts