'How to create TCP tunnels with Pagekite

I am a complete beginner when it comes to networking and I am trying to set up a TCP tunnel on my machine using pagekite. I want to route all traffic from a TCP address to a port on my localhost, let's say 8080. I would then start a handler on localhost:8080 to deal with the incoming traffic. I can get this to work with ngrok simply by doing ngrok tcp 8080, but on a free ngrok plan I cannot reserve tcp addresses and ngrok is rather slow, so I opted to try and use pagekite.

Pagekite normally allows easy tunnelling to an HTTP address, but they have a guide here about how to use PuTTY along with Pagekite to create a TCP tunnel proxied by HTTP.

I followed their guide but could use some help figuring out if it does what I want it to do.

I am working on a Linux VM, so I first set up an SSH server with openssh like this: sudo service ssh start

I then exposed that SSH server using pagekite like this: python3 pagekite.py 22 ssh:user.pagekite.me

I then started PuTTY, and configured the Host Name to be user.pagekite.me on port 22, setup an HTTP proxy with the proxy hostname user.pagekite.me on port 443 and finally created a tunnel from the PuTTY machine with source port 8080 and destination localhost:8080.

Now I am not sure what this actually accomplished. I know that the PuTTY machine connected to the ssh server running on my VM and I am able to use the linux terminal from the PuTTY terminal but has this actually created a TCP tunnel from user.pagekite.me:8080 to localhost:8080? Additionally after doing this, if I try to setup the handler on localhost:8080 I get the following error:

Handler failed to bind to 0.0.0.0:8080
Rex::BindFailed The address is already in use or unavailable: (0.0.0.0:8080).

Again I am completely clueless when it comes to networking so if anyone could explain what it is I'm doing and if it is even possible to do what I want the way that I am doing it, that would be quite helpful.



Solution 1:[1]

You should not care about user.pagekite.me:xyz, this is what the user will connect to, the user will connect to user.pagekite.me and its done.

How this connects to you on your local server? Well, you receive connection on localhost:port via PuTTY or alike, which port? The port you wrote in terminal python3 pagekite.py (port) user.pagekite.me

In your case, PuTTY will connect to localhost:22 not 8080

this is from pagekite website

Pagekite quick start guide

Flying kites - Apache, nginx, ...

Assuming you have a web server (for example Apache or Nginx) running on port 80 on your local machine, the following command will make it publicly visible:

$ pagekite.py 80 foo.pagekite.me This will connect your localhost:80 web server to the publicly visible http://foo.pagekite.me/. More importantly, it will also allow you to use SSL/TLS encryption on https://foo.pagekite.me/. We recommend using the encrypted versions whenever possible!

You can replace 80 with other port numbers (3000 and 8000 are common values for web development).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1