【发布时间】: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