【发布时间】:2018-02-26 23:09:39
【问题描述】:
我有一个从 Visual Studio 2017 Basic Azure Node.js Express 应用程序生成的 node js express 应用程序。我假设 Azure 部署所需的所有配置都在模板附带的 Web.config 文件中设置,但在 Azure 发布后我收到此错误:
iisnode 在处理请求时遇到错误。 HRESULT:0x2 HTTP 状态:500 HTTP 子状态:1002 HTTP 原因: 内部服务器错误 您收到此 HTTP 200 响应是因为 system.webServer/iisnode/@devErrorsEnabled 配置设置为 '真实'。
除了node.exe进程的stdout和stderr的日志, 考虑使用调试和 ETW 跟踪来进一步诊断 问题。
node.exe 进程没有向 stderr 写入任何信息或 iisnode 无法捕获此信息。常见的原因是 iisnode 模块无法创建日志文件来捕获 node.exe 的 stdout 和 stderr 输出。请检查身份 运行 node.js 应用程序的 IIS 应用程序池已读取 并写入对服务器上目录的访问权限 node.js 应用程序位于。或者,您可以禁用日志记录 通过设置 system.webServer/iisnode/@loggingEnabled 元素 web.config 为“假”。
如果我在不修改任何内容的情况下发布应用程序,它运行良好,但是当我添加我的静态文件并添加相关模块时,它开始给我上面的错误。下面是我的 web.config 文件
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>
<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="node.exe --debug"/>-->
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
<!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
<!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/67499f58-9ba1-441d-b23f-6d860606ddb5" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
<!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
<match url="^ntvs-debug-proxy/.*"/>
</rule>-->
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
<!--<system.web>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>-->
</configuration>
【问题讨论】:
标签: node.js azure express visual-studio-2017