这可能是一个非常简单的问题,但我可以在安装了IIS的Windows Server 2008环境中使用Node.js吗?是否有“Microsoft”库或其他更好的解决方案可用?
您可以通过两种方式在IIS上运行Node.js应用程序。
如果您要将整个应用程序专门用于Node.js,并且仅需要公共终端点通过现有的IIS应用程序工作,我建议使用ARR将整个站点路由。 我正在为几个项目执行此操作,效果还不错。
老实说,我不喜欢IISNode,因为它似乎是在您的节点代码中创建外来终端点而不是IIS。 它能工作,如果您特别针对Azure,则可能是最佳选择。 如果您必须将其塞入现有的.Net应用程序中,则也可能是最佳选择。
我一直在Windows上使用Cygwin和Node,遇到了一些问题。你可以使用IIS在默认端口80上提供服务,并在不同的端口上运行Node应用程序。
如果想要代理,大多数人都使用Nginx。
我想尽可能地让它变得简单。
我安装了iisnode并运行了示例,没有任何问题,但是...
我尝试使用iisnode在IIS上部署它,但我必须捆绑我的meteor应用程序,然后将其部署为节点应用程序。我遇到的问题让我感到沮丧。我根本无法安装 fibers
。编译过程一直报错,所以我放弃了。
我为自己解决这个问题的方法是在IIS上使用反向代理。
My final web.config entry was:
I did the same, however, the way I had the reverse proxy on IIS to use a sub folder on the domain threw me of.
I was not aware that by using ROOT_URL we could specify the a sub path.
example, if i run the following command inside my meteor app folder:
set ROOT_URL=http://localhost:3100/n/todos && meteor
I will be able to access my app at
http://localhost:3100/n/todos
, notice I omitted the trailing/
. And if we try to surf to the addresshttp://localhost:3100/n
orhttp://localhost:3100/
will give us an errorUnknown path
.So, when I first setup the reverse proxy, I was getting the
Unknown Path
error every time.Turns out that on my IIS config, I have to specify the
http://localhost:3100/n/todos
as the url value on the action, please notice the "n/todos" at the end.So my rewrite rule ended up like this: [file @ c:/inetpub/wwroot/web.config]
``` <configuration> <system.webServer> <rewrite> <rules> <rule name="TODOs meteor app. Route the requests" stopProcessing="true" enabled="true"> <match url="^n/todos/(.*)" /> <conditions> <add input="{CACHE_URL}" pattern="^(https?)://" /> </conditions> <action type="Rewrite" url="{C:1}://localhost:3100/n/todos/{R:1}" /> <!-- I was missing the /n/todos here --> <serverVariables> <set name="HTTP_ACCEPT_ENCODING" value="" /> </serverVariables> </rule> </rules> <outboundRules> <rule name="TODOs ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="false"> <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://localhost:3100/(.*)" /> <action type="Rewrite" value="/n/todos/{R:2}" /> </rule> <rule name="TODOs RewriteRelativePaths" preCondition="ResponseIsHtml1" enabled="false"> <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" negate="false" /> <action type="Rewrite" value="/n/todos/{R:1}" /> </rule> <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:3100/(.*)" /> <action type="Rewrite" value="http{R:1}://localhost/{R:2}" /> </rule> <preConditions> <preCondition name="ResponseIsHtml1"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> </rewrite> </system.webServer> </configuration> ```
谢谢