IIS返回500,当节点的应用程序返回4XX [英] IIS returns 500 when Node app returns a 4xx
问题描述
我也问过这个在 iisnode GitHub的项目
我通过Windows Azure的网站使用IISNode。
I am using IISNode via a Windows Azure Website.
如果我的节点的应用程序返回2xx状态code(200,201等),那么一切都很好,按预期工作。
If my Node app returns a 2xx status code (200, 201, etc), then all is well and works as expected.
如果我的节点的应用程序返回4xx状态code,例如: response.send(404,未找到)
(我用的RESTify)然后我得到发送到客户端500和简直是无法显示身体页因为发生内部服务器错误。
if my Node app returns a 4xx status code, for example:
response.send(404, "not found")
(I am using Restify) then I get a 500 sent to the client and the body is simply "The page cannot be displayed because an internal server error has occurred."
如果我蔚蓝的网站日志结尾<网站名称方式>
,那么当500被发送到客户端,日志中包含一个404的HTML
If I do azure site log tail <sitename>
, then when the 500 gets sent to the client, the log contains HTML of a 404.
...
<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>
...
我真的只是想IISNode / IIS把我的404,并将其发送下来到客户端。这也是401S,409s,等真正的他们都导致500获得送吧。
I really just want IISNode/IIS to take my 404 and send it on down to the client. This is also true of 401s, 409s, etc. They all cause a 500 to get sent instead.
我曾尝试&LT;的customErrors模式=关/&GT;
和&LT; httpErrors existingResponse =直通/&GT;
在我的web.config无济于事。这是我现在的web.config:
I have tried <customErrors mode="off" />
and <httpErrors existingResponse="passThrough" />
in my web.config to no avail. Here is my web.config now:
<?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>
有关它的价值,我不能让IISnode做任何事情,但是从我的节点应用程序返回200S。试图让IIS服务于我的静态文件,使节点检查,或者任何其他的更有趣IISNode功能造成500我。不知道为什么,很想得到过去吧!
For what it's worth, I can't get IISnode to do anything but return 200s from my node app. Trying to get IIS to serve my static files, enable node-inspector, or really any of the more interesting IISNode features cause a 500 for me. No idea why, and would love to get past it!
<一个href=\"http://stackoverflow.com/questions/15144405/windows-azure-websites-is-overriding-my-404-and-500-error-pages-in-my-node-js-ap\">this问题是pretty多的究竟的我的问题。除&LT; httpErrors existingResponse =直通/&GT;
不为我工作。我觉得我有一些更根本性的错误我IISNode的设置,因此,如果任何人有任何的事情的想法去尝试,我所有的耳朵。
this question is pretty much exactly my problem. Except that <httpErrors existingResponse="PassThrough" />
does not work for me. I feel like I have something more fundamentally wrong with my IISNode setup, so if anyone has any ideas on things to try I'm all ears.
推荐答案
由于某种原因,在你的配置以下部分导致此问题:
for some reason the following section in your config is causing this issue:
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>
作为解决办法,如果可能的话除去这部分,然后重试。我将调查为什么这部分导致了此问题。
As a workaround, remove this section if possible and retry. I will investigate why this section is causing this issue.
这篇关于IIS返回500,当节点的应用程序返回4XX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!