首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用iisnode的权限和请求

使用iisnode的权限和请求
EN

Stack Overflow用户
提问于 2017-07-19 22:37:55
回答 2查看 3.7K关注 0票数 2

我运行我的Node.js应用程序,得到一个严重的错误

代码语言:javascript
复制
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的连接。

EN

回答 2

Stack Overflow用户

发布于 2017-07-20 15:25:46

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

这是我的server.js

代码语言:javascript
复制
const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.send('Hello World!')
})

app.listen(3000)

web.config中,我有:

代码语言:javascript
复制
<?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

票数 2
EN

Stack Overflow用户

发布于 2018-08-22 16:25:51

希望这能有所帮助。我也遇到了这个问题,我不得不花很多时间调查如何解决,是否所有与权限相关的更改等等。但最后我想试一试,给出bin/www路径而不是server.js (在我的例子中它是app.js),它起作用了:)。

我的web.config文件如下所示

代码语言:javascript
复制
<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>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45193863

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档