站长图库向大家介绍了Node.js,iis部署运行node等相关知识,希望对您有所帮助
本篇文章给大家介绍怎么使用Node.js中iis部署运行node,我们一起看看怎么做。

从linux迁移到windows server,一言难尽。网上有说iis已经支持node了。IIS Node折腾了一下,没跑起来,估计兼容性不是那么好,索性放弃了。直接pm2部署了。
IIS Node地址:https://github.com/tjanczuk/iisnode/wiki/iisnode-releases
安装了IIS UrlRewrite 地址:https://www.iis.net/downloads/microsoft/url-rewrite
在站点根目录创建web.config, 内容如下
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}" redirectType="Found" /> </rule> <rule name="root"> <match url="^(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^chuchur.com$" /> </conditions> <action type="Rewrite" url="http://127.0.0.1:7005/{R:1}" logRewrittenUrl="true" /> </rule> <rule name="path"> <match url="^(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^www.chuchur.com$" /> </conditions> <action type="Rewrite" url="http://127.0.0.1:7005/{R:1}" /> </rule> </rules> </rewrite> </system.webServer></configuration>其中有三条规则,第一条是https的转发
第二条和第三条分别是把来源是主记录(chuchur.com)和别名(www.chuchur.com)的统统转发到node端口上。
剩下的就是一个SPA文档站点 (vue)
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="rest" stopProcessing="true"> <match url="^rest/(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="http://127.0.0.1:7005/rest/{R:1}" /> </rule> <rule name="root"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> &nb

