Using ngrok with IISExpress on windows

I'm used to using a Mac, and ngrok is a breeze; all you have to do is specify the port, but I am new to IISExpress and I cannot figure out how to use ngrok and / or IIS correctly. To be clear, I inherited a Windows computer from an employee (who left the company), and the setup works fine in place.

The local url is similar to:

thing.somedomain.com 

In the IIS bindings section, I have:

 Type Host Name Port IP Address http thing.somedomain.com 80 * 

I used this page for reference: https://www.twilio.com/blog/2014/03/configure-windows-for-local-webhook-testing-using-ngrok.html

The instructions seem reasonable, but they do not work for me. These instructions show that the applicationhost.config file needs to be changed for IIS. I found this file and found the correct section for the site that I need for ngrok. The binding information does not match what in IIS gui:

 <binding protocol="http" bindingInformation="*:4085:localhost" /> 

In accordance with the instructions, I added:

 <binding protocol="http" bindingInformation="*:4085:whatever.ngrok.io" /> 

(Here every time I run ngrok on windows, I get ngrok.io instead of ngrok.com, which seems strange. I tried to access both paths with no luck.)

I restarted the site in IIS (in the action menu). When I try to access the ngrok url from the remote machine, ngrok returns 502 bad gateways, and the remote machine shows:

 Failed to complete tunnel connection The connection to http://whatever.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:4085. Make sure that a web service is running on localhost:4085 and that it is a valid address. The error encountered was: dial tcp 127.0.0.1:4085: ConnectEx tcp: No connection could be made because the target machine actively refused it. 

When I try to go to localhost: 4085 locally, I get "This webpage is unavailable." When I try to switch to localhost: 80, I get a redirect to another site serving IIS. When I try 127.0.0.1:80, I get a 404 error.

I tried using netstat -a -b and tried all the ports associated with 127.0.0.1 and nothing works on the correct site (but still thing.somedomain.com still works correctly).

I am completely puzzled and do not know what to do next or where the problem is (how I start ngrok, how I access ngrok, how bindings bind, how IIS reboots, firewall problem or some other voodoo ) It should be just bloody!

+5
source share
1 answer

So, it turns out that nothing has changed in the ApplicationHost.config file, and I searched for the wrong ApplicationHost.config file (the real file is usually hidden from view in C: / Windows / System32 / inetsrv / Config, but you can open it in Notepad from the command line with elevated privileges ("Run as administrator")). The actual binding information was:

 <binding protocol="http" bindingInformation="*:80:thing.somedomain.com" /> 

This is what complies with the IIS metric. However, I needed to change the way I called ngrok:

 ngrok http -host-header=thing.somedomain.com:80 

And that’s all. I also allowed external hostname traffic with this:

 netsh http add urlacl url=http://thing.somedomain.com/ user=everyone 
+7
source

All Articles