iisnode的权限和请求 [英] Permissions and request with iisnode

查看:101
本文介绍了iisnode的权限和请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行Node.js应用程序,但出现了严重错误

I run my Node.js app and I got a heavy error

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,我已经设置好了,即使我删除它也遇到了同样的错误.

Some say that error is from env.Port others say that is from webconfig that I need to set to server.js ,I set it already ,even if I delete it I got the same errors.

我尝试使用iis客户端设置权限

I tried with iis client to set permissions

3天之内我都无法弄清楚自己做错了什么,无论是否使用web.cofig,我都尝试过. 我想念什么吗? 此外,还使用Azure门户提供的字符串设置了与MongoDB的连接.

In 3 days I can't figure out what I did wrong,I tried with and without web.cofig. Am I missing something ? Also the connection to MongoDB is set with the string provided by Azure portal.

推荐答案

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

I am able to reproduce the exact same error.

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

With these configurations, I can visit https://{mysitename}.scm.azurewebsites.net/api/vfs/site/wwwroot/iisnode/index.html to see the detailed error.

app.listen(3000)更改为app.listen(process.env.PORT || 3000)后,我开始使用它.

After changing app.listen(3000) to app.listen(process.env.PORT || 3000), I got it to work.

有关此的更多信息:

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆