Category Archives: Tools

Share your localhost development environment online – The fastest and easiest way to ssh tunnel your local web server

Today, again, I needed to show the progress of an un-deployed application to the customer. It’s not rare at all to have a request to give an online link of your localhost environment. There are a numerous of solutions to this problem, especially if you have a static ip and you fully control your router and firewall ports you can do some magick and provide a public online url for your localhost.

But in most cases this can be tricky or un-doable. In my opinion the most effective way to show your localhost is to use ssh tunneling. This was a common practice back when facebook apps weren’t open to cross site connection and facebook app developers where used to open an ssh tunel to test and run their app in development environement.

Today, I run into the easies way to share your localhost environment via ssh tunel and with the help of a ruby gem called localtunel. The project is developed by Jeff Lindsay and it is supported by Twilio.

Let’s see now how it works.
First of all you need to have ruby installed in your local evnironment. To make sure you have ruby install, run

which ruby

and if you don’t get an answer try installing ruby via rvm.

After that you need to install this gem in the particular ruby version. So try

sudo gem install localtunnel

or try without sudo if you are using an rvm installed ruby.

The last thing to keep in mind is that you need to have an ssh key and provide the path of your ssh public key. In case you don’t have one, follow the instructions from github on how to generate an ssh key .

Supposing that your public key is under ~/.ssh/ , the last step to take is to run

Savvas-Georgious-MacBook-Pro:.ssh savvasmsc$ localtunnel -k ~/.ssh/ 80 This localtunnel service is brought to you by Twilio. Port 80 is now publicly accessible from ...

for the default port of 80 of a typical webserver or

$ localtunnel -k ~/.ssh/ 3000

for a typical rails server etc.

When finished remember to kill the tunneling that exposes the local development environment to the whole internet with a Ctrl-C.

You can also have a look into the source code of this implementation here