Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname

*爱你&永不变心* 提交于 2019-11-28 14:56:32

Troubleshot this issue with ngrok. In the words of inconshrevable, some applications get angry when they see a different host header than expected.

Running the following command should fix the problem:

ngrok http [port] -host-header="localhost:[port]"

Following command will fix the issue

ngrok http -host-header=localhost 8080

This didn't work for me. you could do the following:

For IIS Express

In VS 2015: Go to the .vs\config\applicationhost.config folder in your project

In VS 2013 and earlier: Go to %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config

Find the binding that says:

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

For me it was a project running on port 5219

change it to

  <binding protocol="http" bindingInformation="*:5219:" />

IIS Express will now accept all incoming connections on that port.

Disadvantage: you need to run IIS Express as admin.

or you could rewrite the host header in Ngrok:

ngrok.exe http -host-header=rewrite localhost:5219

The simplest thing for me was using iisexpress-proxy + ngrok.

First I install iisexpress-proxy globally with npm

npm install -g iisexpress-proxy

Then I proxy my localhost with it. Say for instance my site is running on 3003.

iisexpress-proxy 3003 to 12345 where 12345 is the new http port I want to proxy to.

Then I can run ngrok on it.

./ngrok.exe http 12345

It just works! 😃

But I think it works only with http. Right now I don't use https to test, but even if it works, usually it's a lot of work as always.

Steps.

  1. Run command on your console from ngrok.exe directory . ngrok http port i.e ngrok http 80 https://www.screencast.com/t/oyuEPlR6Z Set

  2. Ngrok url to your app .

It will create a tunnel to your application.

Thanks .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!