【问题标题】:Permissions and request with iisnode使用 iisnode 的权限和请求
【发布时间】:2018-08-22 16:25:51
【问题描述】:

我运行我的 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 的连接是使用 Azure 门户提供的字符串设置的。

【问题讨论】:

    标签: node.js azure express iis iisnode


    【解决方案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 application returns error: iisnode encountered an error when processing the request HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002

    【讨论】:

    • 在尝试了 5 天后,我也尝试了这个解决方案,但对我不起作用,我尝试做 MongoDB 教程,但在 git push 'gulp failed' 之后得到了
    • 你能从上面的链接中总结一下重要的细节吗?因为墙上有那个网站的标志?
    【解决方案2】:

    希望这会有所帮助。我也遇到了这个问题,我不得不花很多时间研究如何解决,是否进行了所有与权限相关的更改等......但最后我想尝试通过提供 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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      • 2016-07-03
      • 1970-01-01
      • 2013-07-31
      • 2016-08-17
      • 1970-01-01
      相关资源
      最近更新 更多