【问题标题】:I can't access my website from outside Windows Server 2012 using IIS and IISNode我无法使用 IIS 和 IISNode 从 Windows Server 2012 外部访问我的网站
【发布时间】:2016-09-09 19:49:27
【问题描述】:

我买了一个新的专用服务器。我有一个 MEAN Stack 应用程序(Node.js、Angular、MongoDB、Express)并希望利用 IIS 来发布我的 webapp。

我跟着 this guide 安装了 iisnode 并使一个小 node.js 服务器工作。

我做到了,并在服务器内部的浏览器中成功尝试了http://iisnode.local

另一方面,如果我尝试http://(theIPoftheserver)/iisnode.local,我会收到以下错误:

我需要做一些事情让服务器可以从外部访问,但我不知道是什么..

如果我去http://(theIPoftheserver)/我可以看到IIS网站,即使我去http://(theIPoftheserver)/node我也可以看到iisnode网站...

我是新手,我需要一些帮助...

我的 web.config 文件:

<configuration>
    <system.webServer>

        <!-- indicates that the server.js file is a node.js application
        to be handled by the iisnode module -->

        <handlers>
            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>


        <rewrite>
            <rules>
                <rule name="sendToNode">
                    <match url="/*" />
                    <action type="Rewrite" url="server.js" />
                </rule>
            </rules>
        </rewrite>

        <iisnode enableXFF="true" />

    </system.webServer>
</configuration>

编辑:我还必须提到我在 windows 的 hosts 文件中有一条新规则,如下所示:

127.0.0.1   iisnode.local

EDIT2:Windows 防火墙可以阻止某些东西吗?我需要断开它吗?

重要编辑 14.09.2016:如果我编辑主机文件并添加:

<server-ip-address> iisnode.local

然后我访问http://iisnode.local 它有效! 我不太明白为什么.. 我不希望我网站的所有用户都修改他们的主机文件,我该怎么办?

我不知道这可能是问题的根源吗?

编辑:我的网站绑定如下所示:

【问题讨论】:

  • 防火墙正常不是问题,因为屏幕截图中显示的错误页面来自 IIS。这似乎是 IIS 配置问题。也许在 IIS 中,您的站点仅绑定到 localhost(127.0.0.1)。
  • 我认为这不是问题,因为我可以从外部看到 /node...
  • 在 OP 中完成的重要版本
  • 将您的外部 IP 添加到您的网站绑定中。 (technet.microsoft.com/en-us/library/bb734869.aspx)。如果这可行,那么我将其放入答案中。
  • 没有。是IIS网站配置绑定,链接有详细说明。

标签: node.js iis iis-8 windows-server-2012-r2 iisnode


【解决方案1】:

当您在服务器中访问您的站点时

http://iisnode.local(按主机名)

同理

http://127.0.0.1/(通过 IP)

所以当你使用IP地址的时候,不要把iisnode.local放在后面。

iisnode.local 是主机名,在 URL 中,您可以使用主机名或 IP,而不是同时使用。

http://(theIPoftheserver)/iisnode.local

等于

http://(IP)/(hostname)

目前,我假设您没有为您的服务器设置公共 dns,访问该站点的正确方法是

http://(External-IP)/

【讨论】:

  • 感谢您的帮助!我只需要在我的域 DNS 配置中创建一个规则。谢谢!!!
  • @Egidi,你做了什么?我有完全相同的问题,发现这篇文章很有帮助。我现在可以通过在我的主机文件中使用 issnode.local 访问该站点。你是如何编辑你的 DNS 来解决这个问题的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-14
  • 2019-02-25
  • 2012-02-20
  • 1970-01-01
相关资源
最近更新 更多