02/08/2017 Featured Christopher Reichert

TL;DR Test APIs behind a firewall or on development machines using ngrok

Try it for yourself with a free Assertible account

1. Download ngrok

The first step is to download a program to expose localhost or another url behind a firewall to the Internet. We'll use ngrok which is a program can be downloaded for free and available for all major operating systems.

https://ngrok.com/download

Download and unpack ngrok.

$ unzip /path/to/ngrok.zip

2. Start ngrok

The next step is to expose your web service. If your web service is on localhost, simply run the following on the command-line:

$ ngrok http 3000

If you need to point ngrok to another host behind a firewall (e.g. inside an intranet), use the full host instead of a port only:

$ ngrok http internal.host:8099

You should see a line that looks something like this:

Forwarding    http://7e9ea9dc.ngrok.io -> 127.0.0.1:3000

or

Forwarding    http://7e9ea9dc.ngrok.io -> internal.host:8099

Copy the *.ngrok.io URL to your clipboard or write it down.

Testing a host that is not localhost

If the web service you are trying to test is using another host that's not localhost, for example http://private.behind-firewall.com, you can make a tunnel by customizing the ngrok command using the -host-header command-line flag:

./ngrok http -host-header=rewrite private.behind-firewall.com:80

3. Create a web service in Assertible

Next, create a web service in the Assertible dashboard.

Create an API pointed at an ngrok url

Use the ngrok URL obtained in step 2 as the host of your Assertible web service (e.g. http://7e9ea9dc.ngrok.io).

4. Start testing!

Assertible will automatically run a test once when you create a new API to help you get oriented with the results.

ngrok Assertible test result

You should see a similar output in ngrok (although you may not have any failures!).

ngrok output

From this point, you are completely setup and free to configure Assertible to test various aspects of your API or web app. Have fun!

Resources and documentation


:: Christopher Reichert

Categories

The easiest way to test and
monitor your web services

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free