通过隧道(使用ngrok)将localhost暴露给Internet:HTTP错误400:错误的请求;无效的主机名 [英] Exposing localhost to the internet via tunneling (using ngrok): HTTP error 400: bad request; invalid hostname

查看:264
本文介绍了通过隧道(使用ngrok)将localhost暴露给Internet:HTTP错误400:错误的请求;无效的主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从先前版本的问题开始,有以下内容:

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.

我想做的是将我在本地主机上运行的网站暴露给Internet.我找到了一个可以做到这一点的工具:ngrok.

What I am trying to do is expose my website running on localhost to the internet. I found a tool that will do this: ngrok.

在Visual Studio中运行网站,该网站在localhost/port#上启动.我在命令行中运行命令"ngrok http port#".一切似乎开始正常.我生成了两个URL,并且ngrok检查URL(localhost:4040)有效.

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.

唯一的问题是,当我转到生成的URL时,出现HTTP错误400:错误的请求无效的主机名.这是与运行"ngrok http错误端口号"时的错误不同的错误,这是未找到主机的错误...因此,我认为正在发生某些情况.我只是不知道该怎么办...

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...

通过隧道服务将网站公开到互联网上,我还缺少步骤吗?如果有,我在ngrok文档中找不到它.

Is there a step I am missing in exposing my site to the internet via the tunneling service? If there is, I can't find it in the ngrok documentation.

推荐答案

使用ngrok解决此问题.用坚不可摧的话来说,某些应用程序看到的主机标头与预期的不同时会生气.

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]"

这篇关于通过隧道(使用ngrok)将localhost暴露给Internet:HTTP错误400:错误的请求;无效的主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆