Simple Hack of the Month: LocalTunnel Made Even Better on dotCloud

Share localhost web servers to the web with dotCloud

Sometimes you want to easily share what you’re running on your laptop without messing with your internet router. Often, this requires a third party solution. With this hack, you can deploy a popular 3rd party solution in a simpler more reliable way.

I like using LocalTunel.com to share what I’m running on my laptop with coworkers who are working remotely or my friends back home in Paris. It is especially usefull when you are working with an API like Twilio which requires access to your app.

But there are drawbacks.

For example, I’ve noticed LocalTunnel.com is often unavailable – likely because it is so popular. More problematically, LocalTunnel doesn’t give you a static url to share. Instead, it generates a new url everytime you restart the tunnel. I found this to be especially frustrating.

I created a simple hack to overcome these obstacles on dotCloud’s platform. You can share your work for free in Sandbox mode.

Just Follow These 5 Steps:

1. Clone the tunnel-on-dotcloud repo to get the config files

git clone

cd tunnel-on-dotcloud

2. Create a dotCloud app 

dotcloud create webtunnel

3. Push on dotCloud

dotcloud push webtunnel

  • You will get a 502 error if you try to access the url at this point because you haven’t created the web tunnel yet.

4. Grab the info needed

dotcloud info webtunnel.proxy

Look for the ssh:// url in the ports section of proxy.0, from which you should grab:

  • The user (should be ‘dotcloud’), let’s call it $USER
  • The hostname (should be something like webtunnel-dotCloudUsername.dotcloud.com, which we’ll call $HOST
  • The port (the 4 digits number after the “:”) which we’ll named $PORT

5. Open the SSH tunnel on your computer

(don’t forget to replace $USER $PORT and $HOST)

If you don’t have any webserver running you can just fire up a simple one using the following: 

  • python -m SimpleHTTPServer

On the other hand if you have one be careful to replace the local port (8080 here) with the one your webserver is listing on.

  • ssh -i ~/.dotcloud/dotcloud.key -l $USER -p $PORT $HOST -R 8042:localhost:8080
If you are lazy like me just alias it in to your .bash_profile or .bashrc 
  • echo “alias webtunnel=’ssh -i ~/.dotcloud/dotcloud.key -l $USER -p $PORT $HOST -R 8042:localhost:8080′” >> ~/.bash_profile

That’s it! You should now be able to get the most out of LocalTunnel’s awesome tool by running it on dotCloud.