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 the local IP working. Then I found ngrok, and apparently I don't need to connect via the IP.
What I am trying to do is expose my website running on localhost to the inte.net. I found a tool that will do this: ngrok.
Running the website in visual studio, the website starts up on localhost/port#. I run the command "ngrok http port#" in the command line. Everything seems to start up fine. I generate a couple of URLs, and the ngrok inspection url (localhost:4040) works.
The only problem is that when I go to the generated URLs, I get an HTTP error 400: bad request invalid hostname. This is a different error than when I run "ngrok http wrongport#", which is a host not found error...so I think something good is happening. I just can't tell what...
Is there a step I am missing in exposing my site to the inte.net via the tunneling service? If there is, I can't find it in the ngrok documentation.
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]"
Depending on the version, you may also want to try:
ngrok http [port] --host-header="localhost:[port]"
以下命令将解决问题
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
对于https
这有效:
ngrok http https://localhost:<PORT> -host-header="localhost:<PORT>"
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.
Try with different locations from the Global infrastructure > Locations
ngrok http -region eu 8080
You can make a request and view any traffic passing through your tunnel using the ngrok traffic inspector at http://localhost:4040 .
OR in command line
ngrok http -region eu 8080 --log=stdout
ngrok runs tunnel servers in datacenters around the world. The location of the datacenter within a given region may change without notice (eg the European servers may move from Frankfurt to London).
对于https
这有效:
ngrok http https://localhost:<PORT> --host-header="localhost:<PORT>"
First open ngrok configuration YAML file, run from terminal:
ngrok config edit
Example of yaml for localhost setup (client & server):
version: "2"
authtoken: {YOUR_AUTH_TOKEN_FROM_NGROK_WEBSITE}
tunnels:
client:
addr: 3000
proto: http
host_header: localhost
server:
addr: 4000
proto: http
host_header: localhost
Save the config file based on your client and server ports and run the following command:
ngrok start --all
This will make ngrok open a tunnel for all the configurations declared in the yaml file
UPDATED COMMAND FOR LATEST VERSION
Tested with: (Windows) (ngrok v3.0.5)
Use --
instead of -
ngrok http --host-header=localhost 8080
I had the same issue and used the following solution:
MAKE SURE YOUR APPLICATION BINDING IN YOUR IIS is set to All Unassigned IP ADDRESS
Run ngrok http 127.0.0.1:173 --region=eu --hostname=yourcustomdomain.eu.ngrok.io
THAT'S IT. WORKS PERFECTLY. THIS SOLUTION IS ALSO FOR PAID PRO ACCOUNTS
In order not to suffer with the settings, just use Myway.cf service. Much more convenient and powerful in my opinion.
Steps.
Run command on your console from ngrok.exe directory . ngrok http port ie ngrok http 80 https://www.screencast.com/t/oyuEPlR6Z Set
Ngrok url to your app .
It will create a tunnel to your application.
Thanks .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.