-->

访问权限,并要求iisnode(Permissions and request with iisno

2019-09-30 16:11发布

我跑我的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。 我缺少的东西吗? 另外要MongoDB的连接设置与天青门户网站提供的字符串。

Answer 1:

我能够重现的确切同样的错误。

这里是我的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)我得到它的工作。

更多内容:

应用的NodeJS返回错误:iisnode遇到一个错误处理请求时HRESULT:0X2 HTTP状态:500 HTTP子:1002



Answer 2:

希望这会有所帮助。 我也得到这个问题,我不得不把大量的时间研究如何解决,做了所有的许可相关的变化等等......但最后我想通过给斌/ 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> 



文章来源: Permissions and request with iisnode