gpt4 book ai didi

node.js - 为什么 Nodejs 应用程序无法在 Windows IIS 上运行

转载 作者:太空宇宙 更新时间:2023-11-03 23:07:45 24 4
gpt4 key购买 nike

我使用nodejs应用程序和express我想在Windows IIS上托管。在我的 IIS8 上,nodejs 正在工作。但我收到错误“无法获取/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而且效果很好。

关于node.js - 为什么 Nodejs 应用程序无法在 Windows IIS 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28659727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com