[英]Can you use node.js with IIS?
这可能是一个非常简单的问题,但我可以在带有IIS的Windows Server 2008环境中使用node.js吗? 是否有“Microsoft”库或其他更好的解决方案?
当然可以,看看IISNode项目 。
你可以在Windows上安装Node.js,但它是它自己的服务器,所以除非你使用IIS作为它的代理,否则根本不需要IIS。 但请注意,以下内容引自Node.js的安装说明 :
[Windows]版本都没有令人满意的稳定性,但可以运行一些东西。
我一直在使用Cygwin的Windows上的Node并且几乎没有问题。 您可以使用IIS在默认端口80上运行,并在不同端口上运行您的Node应用程序。
如果你想代理,那么大多数人都在使用Nginx。
设置Windows + IIS + Node.js + Mongodb以构建快速todo应用程序的演练
http://www.amazedsaint.com/2011/09/creating-10-minute-todo-listing-app-on.html
我想让它变得尽可能简单。
我安装了iisnode并且没有问题地运行了样本但是......
我尝试使用iisnode在IIS上部署它,但我必须捆绑我的meteor应用程序,然后将其部署为节点应用程序。 我遇到的问题让我气馁。 我根本无法安装fibers
。 编译过程中不断出现错误,所以我放弃了。
我为此解决的问题是在IIS上使用反向代理。
我最后的web.config条目是:
我做了同样的事情,但是,我在IIS上使用反向代理的方式使用域上的子文件夹引起了我的注意。
我不知道通过使用ROOT_URL我们可以指定一个子路径。
例如,如果我在meteor app文件夹中运行以下命令:
set ROOT_URL=http://localhost:3100/n/todos && meteor
我将能够在
http://localhost:3100/n/todos
访问我的应用程序,注意我省略了尾随/
。 如果我们尝试浏览地址http://localhost:3100/n
或http://localhost:3100/
将给我们一个错误Unknown path
。因此,当我第一次设置反向代理时,每次都会收到“
Unknown Path
错误。事实证明,在我的IIS配置中,我必须指定
http://localhost:3100/n/todos
作为操作的url值,请注意最后的“n / todos” 。所以我的重写规则最终如下:[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> ```
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.