Exposing a web service on your local computer
Imagine that you are building a webservice on your local computer, and you would like to let someone else access this webservice to test it. This would involve some steps before the other person is able to access your service.
You’d have to configure your firewall settings to allow incoming traffic to the port of your local webserver. Very often you also need to configure NAT, to route the incoming traffic on a port on the router to the service on your local computer, as well with some configurations on the side of your ISP. Another option would be to deploy your application on a publicly available server in the cloud, but this also involves some configuration.
Imagine that there was one simple tool that takes al this configurations and actions away.. Say hello to the ngrok http tunnel.
ngrok http tunnel
Ngrok is a small light-weight tool that allows you to expose a webservice (or even non-HTTP services) on your local by running 1 simple command. What ngrok will do, is initiate a web tunnel between your local service and their cloud platform. It will provide you a web URL (something like http://yourservice.ngrok.io) that you can give to others. Others will be able to access your local service via this link, ngrok will forward the requests via this tunnel towards your service.
This tiny light-weight tool makes it very easy to let other people quickly test your services without having the burden to deploy or configure your firewall.
Okay, I’m convinced! Tell me how
To start up the tunnel, you’ll have to install ngrok, which you can download here: https://ngrok.com/download
When it is installed, you can run it from the commandline using the
If your service is running on port 8080, just run:
ngrok http 8080.
It will then provide you a link that you can give to others, and they will end up on your application when they navigate to this link. It also exposes a little dashboard on your localhost on port 4040 (http://localhost:4040) that provides you some handy metrics. E.g. which status codes were returned, how many connections are there and all the calls that were done.
This makes ngrok an awesome tool for receiving quick feedback on what you’re building!