Wednesday, June 13, 2012

Installing Localtunnel on Mac OSX

Localtunnel is a nifty little application that allows you to share your local webserver with the outside world.  The flow is pretty simple:

  • Run your local webserver
  • Localtunnel spits out a URL for you (ie: 'http://localtunnel.com/abcdefg')
  • Share the localtunnel URL with anyone and they should be able to access your 'localhost' remotely over the web, as long as localtunnel continues to run in the background.
This is ideal for sharing quick demos/prototypes.  It is not a good temporary hosting solution because localtunnel shuts you out after ~20 mins if the service is not actively used.  

Installing this *should* be pretty easy but about a million posts online show that there is a little hidden step that makes this 10 minute process take 2 hours to figure out:
  • You need ruby to install localtunnel according to their documentation:
    • Download XCode through the app store
    • Open XCode:
      • Navigate to XCode ->Preferences->Downloads
      • Install 'Command Line Tools'
  • Open up terminal and run 'sudo gem install localtunnel'
  • run 'localtunnel 80'.  You should get a message saying 'Failed to authenticate.'  To get around this, you need to upload a public key.
    • Make sure you have a public key
      • Run 'cd ~/.ssh'
        • If the directory doesn't exist, created it by running 'mkdir ~/.ssh' and navigate into it by running 'cd ~/.ssh'
      • If you do not have a private/public key pair (ie: id_rsa), create one by running 'ssh-keygen -t rsa -b 4096'
    • Run 'localtunnel -k ~/.ssh/id_rsa.pub 80' and enter your passphrase.
    • The service should now be running.  Take the url displayed and type it in your browser; you should be taken directly to your localhost index page.

2 comments:

Kaz C. said...

awesomeness thank you.

Kaz C. said...

awesomeness. just what i was looking for.