GT4 Design + Web

Dev Tools: NGrok

Dev Tools: NGrok

Dev Tools: NGrok

As a developer, I am always on the look out for cool tools that will make my job that little bit easier.

One of the tasks that I find quite tedious is the process of setting up IIS Express to allow remote connections. This process involves configuring the Windows Firewall and adding entries to the applicationhost.config file to specify the host and port name that the website can be accessed on.

Although it’s not really a complicated process, it’s just more annoying to have to do this for every website/application that I want accessible remotley.

So, how can this be made easier? Step forward... NGrok!

NGrok is an application and service that will allow you to create secure tunnels to your localhost. This is extremly useful for when you want to expose a local server behind a NAT or firewall to the internet. In my case, this was IIS Express.

NGrok will allow development sites to be exposed for various reasons such as allowing a client to quickly view a website/application, live debugging and pointing mobile applications to a resource such as a REST API for testing/developing.

Personally, I have found it especially helpful for implementing WebHooks from other services such as BitBucket and GitHub etc.

To get started using NGrok, all you need to do is download and install NGrok for your desired platform and you should be good to go. It currently comes within a zip file, so all you need to do is unzip the contents and move the ngrok application to your desired location. I moved mine to: C:\Apps\ngrok\

Next, you will need to open up a command prompt or terminal with the working directory set to where the ngrok application file is located and execute the following command:

ngrok http 8080


* 8080 should be substituted for the relevant port number.

If the command executes succesfully, the command prompt should change to display something similar to the following:

NGrok Command Prompt

TIP: It may also be a good idea to add the location of where the ngrok application is located to your System Path. Meaning that you should be able to execute NGrok from a command prompt or terminal, regardless of what the current working directory is.

 

IIS Express

The first time I used this tool to expose a site hosted through IIS Express, it didn’t seem to work as expected and got the following error message after successfully executing the command and then trying to access the site using the specified URL:

  • Bad Request - Invalid Hostname

This is likely due to how the requests are handled for IIS Express.

So, when using IIS Express, this needs to be done slightly differently as to the normal method as outlined above. Instead of the command above, you should enter the following command:

ngrok http 8080 -host-header="localhost:8080"


* 8080 should be substituted for the relevant port number.

 

Previous Post Next Post

About the author

Chris has over a decades's experience in developing website and software applications. Chris is responsible for the day to day running of our website development projects and is a highly skilled .NET developer with a passion for developing cutting edge apps.

When not in front of the computer screen coding away, Chris likes watching movies with his family and DJ'ing in his bedroom.

Related Articles

There are no related articles.

Twitter Feed