为什么 Nodejs 应用程序不能在 Windows IIS 上运行
Why doesn't Nodejs app work on Windows IIS
我将 nodejs 应用程序与 express 一起使用,我想在 windows IIS 上托管。在我的 IIS8 上,nodejs 正在运行。但是我得到了一个错误 'Cannot GET /node/server.js',我在 web.config 中放置了重写规则。然后我收到以下错误。
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
我在网上发现的。每个人都建议以下配置,但不适用于我的 windows
我的 web.config 文件是:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument>
<files>
<add value="server.js" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
</rule>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<iisnode nodeProcessCountPerApplication="8" watchedFiles="*.js;node_modules\*;routes\*.js;views\*.html"/>
</system.webServer>
</configuration>
有什么建议吗?
谢谢
您的配置文件看起来有效。所以,你必须安装 iis rewrite extension 并且它运行良好。
我将 nodejs 应用程序与 express 一起使用,我想在 windows IIS 上托管。在我的 IIS8 上,nodejs 正在运行。但是我得到了一个错误 'Cannot GET /node/server.js',我在 web.config 中放置了重写规则。然后我收到以下错误。
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
我在网上发现的。每个人都建议以下配置,但不适用于我的 windows
我的 web.config 文件是:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument>
<files>
<add value="server.js" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
</rule>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<iisnode nodeProcessCountPerApplication="8" watchedFiles="*.js;node_modules\*;routes\*.js;views\*.html"/>
</system.webServer>
</configuration>
有什么建议吗? 谢谢
您的配置文件看起来有效。所以,你必须安装 iis rewrite extension 并且它运行良好。