Exposing localhost via a tunnel

I came across this tool, localtunnel, that offers a way to expose a localhost based webserver (for example) to the internet. It is a reverse proxy that brings you to your machine way behind a firewall by bouncing off of a externally reachable host running localtunnel.

I tested it out on my Fedora 16 laptop (all I had to do was to run “gem install localtunnel” as I had ruby already installed).

I like the idea, but am not entirely convinced about the security exposure.

3 comments


  1. I like the idea too. It going through a third-party server like localtunnel.com, thus i am not comfortable. May be Fedora can have it’s own like this but have the capability like openvpn-als.


  2. Could someone try if service http://localtunnel.com is still working ?

    I tried:

    sudo apt-get update
    sudo apt-get install -y ruby-full
    sudo apt-get install -y rubygems1.8
    sudo gem install localtunnel

    on my Raspbian. And result?

    CODE: SELECT ALL
    root@raspberrypi:/home/pi# localtunnel -k ~/.ssh/id_rsa.pub 22
    /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:103:in `block in next_packet’: connection closed by remote host (Net::SSH::Disconnect)
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:93:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:93:in `next_packet’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:172:in `block in poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:152:in `next_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb:45:in `get_parameters’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb:118:in `generate_key’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb:51:in `initialize’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:348:in `new’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:348:in `exchange_keys’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:196:in `proceed!’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:187:in `send_kexinit’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:142:in `accept_kexinit’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:189:in `block in poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:204:in `block in wait’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:202:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:202:in `wait’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:81:in `initialize’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh.rb:186:in `new’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh.rb:186:in `start’
    from /var/lib/gems/1.9.1/gems/net-ssh-gateway-1.2.0/lib/net/ssh/gateway.rb:74:in `initialize’
    from /var/lib/gems/1.9.1/gems/localtunnel-0.3/lib/localtunnel/tunnel.rb:44:in `new’
    from /var/lib/gems/1.9.1/gems/localtunnel-0.3/lib/localtunnel/tunnel.rb:44:in `start_tunnel’
    from /var/lib/gems/1.9.1/gems/localtunnel-0.3/bin/localtunnel:47:in `’
    from /usr/local/bin/localtunnel:23:in `load’
    from /usr/local/bin/localtunnel:23:in `’
    root@raspberrypi:/home/pi#

    It doesn’t work. But why?

    For port 80 – the same:

    CODE: SELECT ALL
    root@raspberrypi:/home/pi# localtunnel -k ~/.ssh/id_rsa.pub 80
    /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:103:in `block in next_packet’: connection closed by remote host (Net::SSH::Disconnect)
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:93:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/packet_stream.rb:93:in `next_packet’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:172:in `block in poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:152:in `next_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb:45:in `get_parameters’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb:118:in `generate_key’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb:51:in `initialize’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:348:in `new’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:348:in `exchange_keys’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:196:in `proceed!’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:187:in `send_kexinit’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:142:in `accept_kexinit’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:189:in `block in poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:167:in `poll_message’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:204:in `block in wait’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:202:in `loop’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:202:in `wait’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh/transport/session.rb:81:in `initialize’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh.rb:186:in `new’
    from /var/lib/gems/1.9.1/gems/net-ssh-2.6.6/lib/net/ssh.rb:186:in `start’
    from /var/lib/gems/1.9.1/gems/net-ssh-gateway-1.2.0/lib/net/ssh/gateway.rb:74:in `initialize’
    from /var/lib/gems/1.9.1/gems/localtunnel-0.3/lib/localtunnel/tunnel.rb:44:in `new’


    • Thanks for the note. I have not tested it on my Raspberry Pi yet, but on my Fedora 18 machine, it works.

      I followed the steps listed in: http://progrium.com/localtunnel/ and fired up a one line python webserver: “python -m SimpleHTTPServer 8000”, opened up port 8000 on my local machine’s firewall and ensured that the router allowed to map in coming port 8000 to my machine on the local lan.

Leave a Reply