I'm using EmbedIO 1.13.0 and Swan.Lite 1.28.0 on Windows 2008 Server R3. I'll put the code I use to start the web server at the end. Apart from that code I have written no other C# code to use the server or extend it with handlers.
The problem I'm experiencing is http://localhost:9696/index.html is showing just fine on my local browser, but when I'm tunneling out of my "NAT prison" with ngrok (see https://ngrok.com/ ) the browser shows:
------------- response begins -------------
502 Bad Gateway
The server returned an invalid or incomplete response.
------------- response ends -------------
There's a lot more detail below; based on some evidence (see below) I am suspecting that ngrok thinks the response from EmbedIO's StaticFilesModule is binary and that might be causing the 502?
Do I need to send some headers back with the static file to indicate the mime type? If yes, how? And should the StaticFilesModule not do that, figuring the mine type to indicate based on the file extension?
Things I tried (see below) that might indicate there's a problem in EmbedIO:
Checking the ngrok raw log I can see that the remote site sent:
------------- request begins -------------
GET /index.html HTTP/1.1
Host: 6d0b157b.ngrok.io
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
X-Forwarded-Proto: https
X-Forwarded-For: 216.108.226.10
------------- request ends -------------
And the server responded with the content of the static file
Looking on ngrok's web console I see no content sent back, but there's a curious message:
Binary response not displayed
Does EmbedIO produce a response that somehow makes ngrok think the response it got is binary? Do I need to send some headers back with the static files to indicate the mime type? If yes, how? And should the StaticFilesModule not do that, figuring the mine type to indicate based on the file extension?
Anyways, here's the very simple code I am using to start the EmbedIO server:
string url = "http://localhost:9696/";
WebServer srv = new WebServer(url);
srv.RegisterModule(new StaticFilesModule(localFiles));
srv.RunAsync();
Thanks for looking at this. I really want to use EmbedIO but I cannot use it if I can't display pages on a publicly available URL.
@geoperez wow, response in less than a minute! Is this a known problem that was already reported by someone else?
I am Joe.M.Finn on facebook, would love to chat via messenger if you want me to try more scenarios.
I'm getting Bad Request

Try to bind to all the network interfaces using http://*:8787. You will need run it as admin.
I'm running the Sample http://b7af8d28.ngrok.io
WOW that fixed it! But sad it requires admin -- there's probably no way around it. Anyways its working now, YAHOO!
Check it out here https://6d0b157b.ngrok.io/
Just for curiosity, what was the issue, and is it a bug or should I always use http://*:8787/ ?
You guys give amazing support!!!!!!!!!!!!!!!!!!!!!!
It's not a bug, this is how Windows handle the network binding. Usually, localhost will allow HTTPSys look for a resource listening 127.0.0.1, but I think ngrok is trying to resolve localhost by IPv6.
ngrok http -host-header="localhost:9696" 9696 should make it so you don't need to run as admin. (trying to solve a different problem and ran across this)
Most helpful comment
ngrok http -host-header="localhost:9696" 9696should make it so you don't need to run as admin. (trying to solve a different problem and ran across this)