iis - 在 Windows 上使用 ngrok 和 IISExpress

标签 iis ngrok

我习惯使用 Mac,ngrok 轻而易举;您需要做的就是指定一个端口,但我是 IISExpress 的新手,我不知道如何正确使用 ngrok 和/或 IIS。需要明确的是,我从一位同事(已离开公司)那里继承了一台 Windows 机器,并且该设置在本地运行良好。

本地 url 类似于:

thing.somedomain.com

在 IIS 的绑定(bind)部分,我有:
Type    Host Name               Port   IP Address
http    thing.somedomain.com    80     *

我已将此页面用作引用:https://www.twilio.com/blog/2014/03/configure-windows-for-local-webhook-testing-using-ngrok.html

这些说明看起来很合理,但它们对我不起作用。这些说明表明需要为 IIS 更改文件 applicationhost.config。我找到了这个文件,并找到了我需要 ngrok 的站点的正确部分。绑定(bind)信息与 IIS gui 中的内容不匹配:
<binding protocol="http" bindingInformation="*:4085:localhost" />

根据说明,我添加了:
<binding protocol="http" bindingInformation="*:4085:whatever.ngrok.io" />

(每次我在 Windows 上运行 ngrok 时,我都会得到 ngrok.io 而不是 ngrok.com,这看起来很奇怪。我尝试过两种方式都没有运气。)

我已经在 IIS 上重新启动了站点(在操作菜单中)。当我尝试从远程机器访问 ngrok url 时,ngrok 返回 502 bad gateway,远程机器显示:
Failed to complete tunnel connection

The connection to http://whatever.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:4085.

Make sure that a web service is running on localhost:4085 and that it is a valid address.

The error encountered was: dial tcp 127.0.0.1:4085: ConnectEx tcp: No connection could be made because the target machine actively refused it.

当我尝试在本地访问 localhost:4085 时,我得到“此网页不可用”。当我尝试访问 localhost:80 时,我会重定向到 IIS 正在服务的另一个站点。当我尝试 127.0.0.1:80 时,我收到 404 错误。

我尝试使用 netstat -a -b,并尝试了与 127.0.0.1 关联的所有端口,但没有找到正确的站点(但 thing.somedomain.com 仍然可以正常工作)。

我完全迷惑了,不知道接下来要尝试什么,或者问题出在哪里(在我如何启动 ngrok,我如何访问 ngrok,绑定(bind)如何映射,IIS 如何重新启动,防火墙问题或其他一些巫术)。这应该很简单!

最佳答案

有一种方法可以使它更容易。假设您的 IISExpress 网站是 http://localhost:63254刚开始ngrok像这样:

ngrok http -host-header=rewrite localhost:63254

关于iis - 在 Windows 上使用 ngrok 和 IISExpress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29972875/

相关文章:

powershell - 在 Powershell 中设置 IIS 绑定(bind)证书时出现问题

Ngrok - 502 错误网关

azure - Azure VM 上的网站设置

asp.net - 如何访问在本地主机 (IIS) 上运行的 ASP.NET Web api

c# - 维持稳定用户 session 的标准方法是什么?

ssl - 找不到 ngrok websocket 安全的证书

mongodb - 使用 ngrok 创建隧道连接到 MongoDB 本地数据库

Python 操作系统错误 : [Errno 98] Address already in use but no port is used

node.js - 从本地网络上的远程计算机访问 NodeJS 服务器显示空白页面

debugging - Visual Studio 2015 : Debug session does not terminate properly