How to create an HTTP tunnel on Linux with httptunnel

HTTP-encapsulated tunnels are useful when you want to use games, IM clients, or P2P sharing applications across restrictive firewalls or proxies which tend to block pretty much everything except well known traffic such as HTTP traffic.

httptunnel is GNU/GPL-licensed free software that allows you to create a bi-directional tunnel encapsulated by HTTP, between client and server. httptunnel works by encapsulating all bi-directional data traffic between client and server inside HTTP requests.

In this tutorial, let me demonstrate how to create an HTTP tunnel using httptunnel.

Install Httptunnel on Linux

httptunnel consists of hts (server) and htc (client) components to establish HTTP tunnels in between.

In order to install httptunnel on Linux (on both server and client side), follow the steps below.

To install httptunnel on Ubuntu, Mint, or Debian:

$ sudo apt-get install httptunnel

To install httptunnel on CentOS or RHEL, first set up Repoforge on your system, and then run:

$ sudo yum install httptunnel

To install httptunnel on Fedora, simply run:

$ sudo yum install httptunnel

Set up an HTTP Tunnel in Linux

In order to set up an HTTP-encapsulated tunnel using httptunnel, refer to the example below.

On server side:

$ sudo hts -F <server_ip_addr>:<port_of_your_app> 80

The above command tells hts to listen on port 80, and to redirect all traffic received on port 80 to <port_of_your_app>

On client side:

$ sudo htc -P <my_proxy.com:proxy_port> -F <port_of_your_app> <server_ip_addr>:80

The above command tells htc to receive traffic on localhost:<port_of_your_app>, which then is redirected to <server_ip_addr>:80, optionally via proxy (in case the client is behind HTTP proxy).

At this point, the application instances running on two end hosts can communicate with each other transparently via an HTTP tunnel.

If you are conscious about the security of plain-text HTTP tunnels, or reduce the risk of firewall blocking, you can consider setting up SSH tunneling, which can protect you against eavesdropping, thereby is more robust against potential firewall fingerprinting.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to create an HTTP tunnel on Linux with httptunnel

  1. From previous post:

    Hi Dan,

    Would you mind doing a tutorial/how-to on running IPv4-only apps (like emule) over IPv6?

    Thanks in advance, and kind regards,

    =======

    BTW Dan, forgot to mention running ArchLinux, and emule would be under Wine, which may make it more difficult. However, there are other Linux native apps that would would benefit from such a tutorial.

    Thanks again...

Leave a comment

Your email address will not be published. Required fields are marked *