我运行我的Node.js应用程序,得到一个严重的错误
iisnode encountered an error when processing the request.
HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1002
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.
In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.
The node.exe process has not written any information to stderr or iisnode was unable to capture this information. Frequent reason is that the iisnode module is unable to create a log file to capture stdout and stderr output from node.exe. Please check that the identity of the IIS application pool running the node.js application has read and write access permissions to the directory on the server where the node.js application is located. Alternatively you can disable logging by setting system.webServer/iisnode/@loggingEnabled element of web.config to 'false'.一些人说错误来自env.Port,另一些人说是来自webconfig,我需要设置为server.js,我已经设置了它,即使我删除了它,我也得到了同样的错误。
我尝试使用iis客户端设置权限。

在3天的时间里,我找不出我做错了什么,我试着使用和不使用web.cofig。我是不是漏掉了什么?此外,使用Azure门户提供的字符串设置到MongoDB的连接。
发布于 2017-07-20 15:25:46
我能够重现完全相同的错误。

这是我的server.js
const express = require('express')
const app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.listen(3000)在web.config中,我有:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<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>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
<iisnode
watchedFiles="web.config;*.js"
node_env="%node_env%"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
maxLogFileSizeInKB="1048"
maxLogFiles="50"
devErrorsEnabled="true" />
</system.webServer>
</configuration>有了这些配置,我可以访问https://{mysitename}.scm.azurewebsites.net/api/vfs/site/wwwroot/iisnode/index.html查看详细的错误。

在将app.listen(3000)更改为app.listen(process.env.PORT || 3000)之后,我让它正常工作。

有关的更多信息:
发布于 2018-08-22 16:25:51
希望这能有所帮助。我也遇到了这个问题,我不得不花很多时间调查如何解决,是否所有与权限相关的更改等等。但最后我想试一试,给出bin/www路径而不是server.js (在我的例子中它是app.js),它起作用了:)。
我的web.config文件如下所示
<handlers>
<add name="iisnode" path="bin/www" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="bin/www" />
</rule>
</rules>
</rewrite>
https://stackoverflow.com/questions/45193863
复制相似问题