How to Expose Localhost Server to the Internet?

There are a number of situation where we want to expose our local server to the internet. Maybe we need to present our website to a client that are currently not deployed yet, or perhaps we need to test out a webhook from a third-party website, and we do not want to create a new deployment to handle it. Luckily, there’s a perfect tool for that.

This is where ngrok comes in.

ngrok is a service that sets up a tunnel between their servers and your local machine. The good thing about ngrok is that it has a freemium model, and the free tier covers most of the basic requirements that you need.

Setting up:#

  1. Go to https://ngrok.com/download.
  2. Download for your operating system.
  3. Unzip /path/to/ngrok.zip into any folder.
  4. Start an HTTP tunnel in the desired port. We can start with 80.
$ ./ngrok http 80

For more options, you can consult the help by running:

$ ./ngrok help

Screenshots:#

That is pretty much it. Now you just need to run your service in port 80, and start receiving traffic.

image

— Console of the current ngrok session.

image

— Visiting the site.

image

— ngrok dashboard at port 4040.

comments powered by Disqus