DEV Community

Cover image for Expose your local ๐Ÿ’ป web server to the world ๐ŸŒ

Expose your local ๐Ÿ’ป web server to the world ๐ŸŒ

Giorgos Kontopoulos ๐Ÿ‘€ on January 17, 2020

Why ? Web developers (mostly) develop on localhost using our preferred tools and languages and have a local server to test what we build...
Collapse
 
andreaksweber profile image
Andreas K. Weber

I've fallen in love with Ngrok to achieve exactly what your post describes:

ngrok.com

Collapse
 
devansvd profile image
Devan

Yeah, ngrok is way simpler to use

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@devansvd thanks for stopping by and the comment.
In what ways is ngrok simpler to use, do you care to explain ?

Thread Thread
 
devansvd profile image
Devan • Edited

Maybe a easy to remember command. Never done registration though. Free Link works for 6 hours. Nice article between.

ngrok http 80

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@devansvd I did not realize you can use ngrok without registering, thanks for sharing.

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@andreasweber if you don't mind please share your thought we one would choose ngrok over solutions above. Or please share why you have actually fallen in love with it.

Thanks for stopping by

Collapse
 
andreaksweber profile image
Andreas K. Weber

There are several reasons, but I must admit, I've never searched for another tool or solution to expose my local services to the open world, without having the hassle configure a bunch of things. Ngrok just works for my use cases.

I heavily rely on third party software to develop web applications (like Auth0 as identity management solution). Most of them send back status updates via webhooks. To reduce overhead and time spent setting everything up I use the custom subdomains feature of Ngrok. With this enabled I am able to configure a consistent webhook endpoint and don't have to reconfigure my development setup, after I stopped the tunnel, to get it going again.

Moreover, with Ngroks local ui I can capture and replay requests. That's awesome to simulate real webhook requests again and again. With one of the latest updates Ngrok implemented the possibility to modify requests before replaying them.

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@andreasweber I guess localhost.run and serveo.net are for simpler use cases than. I did not know ngrok had all those bells and whistles but again I never had the need for them and wanted something very simple.

Thanks for the write up

Collapse
 
dexygen profile image
George Jempty • Edited

"Now you can give 1 of the above links to anyone to access on the internet" -- this is against most service providers' terms of service today. Nevertheless the following has been around for 15+ years: dyn.com/remote-access/

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@dexygen "this is against most service providers" not sure what this means, care to explain ?

dyn.com/remote-access/ sure is an alternative but you do need register before using or not ?

Collapse
 
dexygen profile image
George Jempty

It means if your internet service provide finds out they can terminate your service. And yeah you probably have to register, but why would that be a deal-breaker?

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@dexygen it is not a deal breaker per se but why register for a simple use case like mine

thanks for the constructive comments so far.

Thread Thread
 
dexygen profile image
George Jempty

Guess I'm just trying to let your readers know a) the potential drawbacks of doing this in general, and b) an alternative, especially since somebody tried your method and it didn't succeed at first. I used to like running servers from my home so I'm interested in general but haven't done so in 15 years or so. Thanks for the article and good luck.

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@dexygen it is not my readers only they are reading your comments as well ๐Ÿ˜œ

I just had this post in my mind and had to let it free. I belive I gave plenty of alternatives (without actual example thought). I am aware that no solution is perfect and therefore all criticism is well received and in good faith.

I am always greatful of insightful comments like yours so please keep it up.

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Just a note: Before you expose any server to the web, check the terms of your ISP's service contract! Some ISPs strictly forbid running public servers on certain plans, and can choose to disconnect your service if you violate those terms.

Spectrum is one such example. While I have no complaints about their service โ€” best I've ever seen on all fronts, actually โ€” I do have to pay a little more for Business Internet to be allowed to run a public server. The terms of Residential service just does not permit it.

Collapse
 
griffinsauce profile image
Joris Griffioen

With these tools you're creating an SSH tunnel and serving to the outside world from their host. How would your ISP even know?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@codemouse92 thanks for your comment, I was not aware this term might be in existence from ISP's side but I was also made aware from another comment earlier thanks for pointing out.

Collapse
 
lardissone profile image
Leandro Ardissone

I like these services but I freak a little about security. Specially this one doesn't have any kind of Privacy statement on their website.
I would prefer something hosted by myself.

There may be some docker images to do that by yourself like: docker-tunnel, docker-tunnel (2), etc.

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@lardissone The way I see this used is for a few minutes running where I need to test a few quick features and then I turn it down again but you are right I would probably not use it for a mission critical web app.

Thanks for mentioning the alternatives though.

Collapse
 
jfbiswajit profile image
Biswajit Biswas

Using "Localhost.run" it says "nothing connected here, check your SSH!"
Any solution?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

run your command with debugging enabled -v like this

ssh -R 80:localhost:3000 ssh.localhost.run -v

and report back with the output might be able to spot what is going on

Collapse
 
jfbiswajit profile image
Biswajit Biswas

Thanks for your reply.
But I still having the same problem. my localhost runs on localhost:80
so I ran this command: "ssh -R 80:localhost:80 ssh.localhost.run -v"
and got the same message: "Nothing connected here, check your SSH!"

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€ • Edited

@jfbiswajit Are you running on windows ?
I have seen this message that might be from the developer of localhost.run and describes the same error message but no solution

news.ycombinator.com/item?id=14035132

perhaps the windows is not supported at the moment but I have never seen this, I will see if I can get my hands on a windows machine and give it a try.

You might want to try serveo solution as well.

Collapse
 
beznet profile image
Bennett Dungan

Whoa, very cool. Will definitely give this a try

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@beznet I was hoping for people to find useful/cool thanks for stopping by and the comments.

Collapse
 
whatthehanan profile image
Hanan Hamza

for bash users you can create a bash alias for it like this:

function localserve(){
ssh -R 80:localhost:"$1" ssh.localhost.run
}

and then use it as localserve 3000

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@whatthehanan thanks for stopping by and for your addition. Indeed it make life easier if one is using this technique a lot.

Collapse
 
gabanz profile image
Faiz Azhar

Also worth mentioning... Cloudflare Argo Tunnel developers.cloudflare.com/argo-tun... can be used with or without registering for an account

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

@gabanz thanks for the comment. Added cloudflare argo tunnel to the list of similar services at the end of the post.

Collapse
 
spidydev profile image
Cicada1033โžฟ

very easy to setup,thanks :)

Collapse
 
zecka profile image
zecka

What's append to serveo ? Is it dead ?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos ๐Ÿ‘€

Yes seems to be not working, I took a note and edited the post, thanks for posting.

Collapse
 
moopet profile image
Ben Sinclair

The first "big" one of these I remember using was localtunnel, which is just the same sort of ssh wrapper. For some reason, when things like ngrok came out everyone forgot about it though.

Collapse
 
burakisleyicii profile image
Burak ฤฐลŸleyici

Localtonet is also one of the good solutions.