Hemanth's Scribes

web

Exposing Your Localhost to the Internet

Author Photo

Hemanth HM

Thumbnail

Exposing Your Localhost to the Internet

Exposing your local web server to the internet is very useful at times, it gets a bit tough when you are on a DHCP.

The most common option being dynamic DNS and port forwarding with firewall turned off, yes it’s a pain!

While exploring for alternatives came across showoff.io which is a paid service, digging more came across a suggestion from latentflip that being a wonderful gem called localtunnel there is another one called pairkit which is still in private beta.

The whole idea is to use SSH to set up reverse tunnels to your localhost through a public server, which has been a very old trick now, but these gems helps one to enjoy this benefit if they don’t have their own public server.

Getting things done with localtunnel :

P.S : Localtunnel is created by created by: jeff lindsay and sponsored by twilio!

$ sudo gem install localtunnel

Run your local web server on any port!

If none

$ python -m SimpleHTTPSever 8080

Generate public SSH keys.

$ ssh-keygen

Run localtunnel, by passing the key and the port to share.

$ localtunnel -k ~/.ssh/id_rsa.pub 8080

And then you must see something like :

This localtunnel service is brought to you by Twilio. Port 80 is now publicly accessible from http://4inx.localtunnel.com

And that’s it! Now you share that URL to anyone you want and they can access your shared host!

#javascript#linux
Author Photo

About Hemanth HM

Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.