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

后端 未结 6 2269
Happy的楠姐
Happy的楠姐 2020-12-12 08:58

From previous versions of the question, there is this: Browse website with ip address rather than localhost, which outlines pretty much what I\'ve done so far...I\'ve got th

相关标签:
6条回答
  • 2020-12-12 09:19

    Following command will fix the issue

    ngrok http -host-header=localhost 8080
    
    0 讨论(0)
  • 2020-12-12 09:31

    For https this works:

    ngrok http https://localhost:<PORT> -host-header="localhost:<PORT>"

    0 讨论(0)
  • 2020-12-12 09:34

    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]"
    
    0 讨论(0)
  • 2020-12-12 09:38

    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
    
    0 讨论(0)
  • 2020-12-12 09:39

    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!

    0 讨论(0)
  • 2020-12-12 09:39

    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 .

    0 讨论(0)
提交回复
热议问题