Mat*_*eer 5 iis azure node.js iisnode
我也在iisnode github项目上问过
我正在通过Windows Azure网站使用IISNode。
如果我的Node应用返回2xx状态码(200、201等),则一切正常,并且可以按预期工作。
如果我的Node应用返回一个4xx状态代码,例如:(
response.send(404, "not found")我正在使用Restify),则会收到500发送给客户端的消息,正文为“由于发生内部服务器错误,无法显示该页面”。
如果我这样做azure site log tail <sitename>,则当500发送到客户端时,日志中包含404的HTML。
...
<body>
<div id="content">
<div class="content-container">
<h3>HTTP Error 404.0 - Not Found</h3>
<h4>The resource you are looking for has been removed, had its name changed,
or is temporarily unavailable.</h4>
</div>
...
Run Code Online (Sandbox Code Playgroud)
我真的只希望IISNode / IIS接收我的404并将其发送给客户端。401、409等也是如此。它们全都导致发送500。
我试过了<customErrors mode="off" />,<httpErrors existingResponse="passThrough" />在我的web.config中没有任何作用。现在是我的web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="off" />
</system.web>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
<match url="/*" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
对于它的价值,我无法让IISnode做任何事情,只能从节点应用程序返回200s。试图让IIS为我的静态文件提供服务,启用节点检查器或其他任何更有趣的IISNode功能对我来说都是500。不知道为什么,很想过去!
这个问题几乎完全是我的问题。除非那<httpErrors existingResponse="PassThrough" />对我不起作用。我感觉我的IISNode安装有一些更根本的错误,因此,如果有人对尝试的事情有任何想法,我会不知所措。
小智 3
由于某种原因,您的配置中的以下部分导致了此问题:
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>
Run Code Online (Sandbox Code Playgroud)
作为解决方法,请删除此部分(如果可能)并重试。我将调查为什么此部分会导致此问题。