gpt4 book ai didi

node.js - iisnode 的权限和请求

转载 作者:太空宇宙 更新时间:2023-11-04 02:03:18 26 4
gpt4 key购买 nike

我运行 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客户端设置权限 enter image description here

在三天内我无法弄清楚我做错了什么,我尝试过使用和不使用 web.cofig。我错过了什么吗?此外,与 MongoDB 的连接是使用 Azure 门户提供的字符串设置的。

最佳答案

我能够重现完全相同的错误。

enter image description here

这是我的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 查看详细的错误。

enter image description here

app.listen(3000) 更改为 app.listen(process.env.PORT || 3000) 后,我就开始工作了。

enter image description here

更多信息:

Nodejs application returns error: iisnode encountered an error when processing the request HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002

关于node.js - iisnode 的权限和请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45193863/

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