Let the world see localhost using ngrok

A situation where we need to expose our localhost to the internet world do exists. Just to mention a few: web development, API development, new product test, or just a for-fun project using new framework. It’s gonna be super fun when we can let people can see our ‘thing” running.

Meet ngrok, a secure tunnel to localhost. This is one of service that I found so useful lately. I don’t have to purchase a domain to share what I am doing to my colleague. One line of ngrok command and the magic happen.

So, that’s all the crappy talk. Let’s just do something.

Suppose we’re having a HTTP web server running on localhost:4000 on a 64 bit Ubuntu server.

Go to https://ngrok.com/download and choose the package based on your platform. In this case we will use Linux 64-bit packages. I am going to use wget as a sample.

wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip

Unzip it. You will see one executable file called ngrok.

Run it using below command.

./ngrok http 4000

It means we are using ngrok with HTTP protocol on port 4000. You will see something like this.

png

ngrok already running

Now we can type http://05ae780c.ngrok.io on browser and see the app has been public.

Well, 05ae780c prefix is quite hard to remember, and if we stop running ngrok then rerun it, the prefix also going to be changed. To solve that problem we must upgrade ngrok to paid plan. ngrok shall give a reserved subdomain for paid account.

Conclusion, ngrok is a very helpful service even in a free service. At least we don’t have to worry on how to let the world see our localhost.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s