By Danny M.
Aug 4, 2016
Sometimes it can be very convenient to access your local development machine from the public network. Setting up something like this can be inconvenient. Your office network is usually shielded from the internet with a router and a firewall and IT managers generally disapprove opening these up for public inbound traffic.
You many be able to configure your home router to forward tragic to your machine, but the process is no fun.
Ngrok was designed with this exact scenario in mind. It that helps you open a secure tunnel from ngrok’s cloud service to a port on your development machine. This means that if you’re developing a cloud service and would like to access it from a public network you can now do so with a few simple steps.
Some typical use cases are:
- You develop a webhook for a cloud service and would like to shorten your debug cycle. So instead of uploading your code to the cloud (say Heroku or AWS) every time you want to test your integration, you can now develop on your own development machine and point your webhook to your own machine via ngrok’s URL.
- You can have co-workers on remote sites access services on your development machine
- Perform mobile device testing over a 3G/4G networks
Ngrok is not the first nor the only tool that provides this functionality, rather it’s main advantages are that it’s secure and VERY easy to set up (ever tried setting up a double proxy using Linux’s socat ? ).
For example, setting up an ngrok tunnel on your Ubuntu based rails server just takes a few steps:
1 – Download from ngrok.com and unzip it
2 – Place the exe anywhere on your machine
3 – Run “./ngrok http 3000” from your terminal, for example: “./ngrok http 3000”
4 – ngrok will display a public link which can be used to access your server from anywhere now
The same will work with any other port as well.
Finally a word of warning. such tools reduce a LAN’s security level since they’re punching a tunnel through the firewall. So it’s advised to avoid keeping such tunnels open for extended periods of time.