ngrok

A new tool (to me) is ngrok a command line tool and online service to allow you to map an external url to a local server behind a NAT or firewall.

It does require sign up to the service but free accounts are available but these use random urls under the ngrok.io domain.

If you start a local developer machine web service or api you can run the command line ngrok and tell it to map it's generated url to a local host url and port number.

NGrok can be started with just the details of the port number you want forwarded.

ngrok http 14446

I found my asp.net application got a bit upset having ngrok forward the request to it. A quick google showed that it required a host header that was being omitted by ngrok. Fortunately, this is easily fixed:

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

The console (with some details redacted) looks like this:

ngrok

Once ngrok is running, it works pretty much as you would expect, with a summary of the latest few hits to the service. If you want more detail and want to be able to dig into a request, you can use a local server instance created by ngrok to examine traffic.

This has made some awkward Azure-hosted website development in .Net core much easier when I can run the service locally and debug while responding to external requests. Triffic! :)