DEV Community

abhishekq61
abhishekq61

Posted on • Edited on • Originally published at Medium

Debug#Host Servers on your localhost

Disclaimer: I am author from Staqlab Tunnel.This blog contains reference to services provided by tunnel-staqlab.
Do give me a thumbs up, if you find this blog useful

One of the major part of coder life is testing.When it comes to stand-alone consoles apps the testing is pretty easy.You just hook up some debug breakpoints in your favourite IDE and hit the debug button and vola you could see all the variables and inspect your code right-in where you placed your breakpoint.

But what if you rely on some external services to get your code working...

As for example, most of the REST/HTTP applications contains webhook routes from external services as a major part of the workflow.

You just want requests from these services to be forwarded to your localhost!!! But wait what, is this possible?
Can your localhost be connected over to the internet and traffic from web is forwarded to your local machine?

Yes this is possible through principles of SSH Tunneling.
There are already tunnels servers like Staqlab Tunnel which forwards traffic from web to your localhost.

The guide on staqlab is pretty self-explanatory. However lets discuss step-by-step procedure here also.
I will assume your server is running on localhost:3000
At the end of this tutorial you will be able to get a public url, which points to server running locally on port 3000.Do mind that the port can be any valid port.It doesn't necessarily be 3000

Step 1:

Download tunnel client for you pc from https://tunnel.staqlab.com/downloads

Step 2:

Go to your downloads folder and unzip the zip file downloaded

Step 3:

Open terminal and navigate to folder where you have placed the downloaded file. and paste below command
./staqlab-tunnel 3000
if you want to have a custom domain.Look, its also possible.Replace above command with below command.
./staqlab-tunnel 3000 hostname=<your-domain>
e.g
./staqlab-tunnel 3000 hostname=kitty-lovers

After following above steps, you will be greeted with 3 urls on your terminal window.

First one, is inspector url. Its a powerful tool where you can investigate and replay all the http/https traffic from/to your server

The second and third url are http and https versions of the the public url which is in this case is

Just copy this url and paste it in your browser and see the magic, you can
see response from your pc on the your browser window.


Share this url with your colleagues, and display your work over the web!!

Top comments (2)

Collapse
 
hkchakladar profile image
hkchakladar

Not working, not getting public link, terminal stuck on initiating connection for hours like this:

$ ./staqlab-tunnel 5000
Inspector Client---->  https://tunnel.staqlab.com/inspector/4000/details
For any issues, recommendations or feature request mail us at admin@staqlab.com

Mail us at admin@staqlab.com to make recommendations or feature request and win $5 if its get accepted.

Buy us a coffee, if you liked the work : https://www.patreon.com/staqlab
Initiating Connection...
CAUTION: we have updated .tunnel.staqlab.com to .staqlab-tunnel.com You may need to update your webhook url if you have registered it with some 3rd party integration
Enter fullscreen mode Exit fullscreen mode
Collapse
 
virgin2378hybrid profile image
virgin2378-hybrid

this tunnel is not working for me but i still keep it
maybe one of this days'it might decide to work, who knows'i need to be kind too......