Man*_*ish 1 asp.net asp.net-mvc nginx appharbor
我刚刚为我的Appharbor Web应用程序设置了"维护"模式.通过设置配置变量,该站点将用户重定向到自定义的"向下维护"页面.我希望以HTTP 503状态返回此页面,因此该站点在关闭时不会被编入索引.我在动作中设置响应代码如下:
public ActionResult Maintenance()
{
Response.StatusCode = 503;
return View();
}
Run Code Online (Sandbox Code Playgroud)
这一切都按我想要的方式在本地服务器上运行.我使用503状态代码获取自定义视图.但是,一旦我部署到AppHarbor,我就会得到一个简单的nginx 503错误页面.似乎nginx可能正在拦截响应并返回自己的错误.有关如何使自定义主体与503状态一起显示的任何想法?这是我看到的原始响应:
HTTP/1.1 503 Service Unavailable
Server: nginx
Date: Fri, 07 Jun 2013 19:26:09 GMT
Content-Type: text/html
Content-Length: 27
Connection: keep-alive
Cache-Control: private
The service is unavailable.
Run Code Online (Sandbox Code Playgroud)
该消息The service is unavailable.实际上是IIS的默认HTTP 503消息.问题是IIS(不是nginx)默认拦截并重写响应.
您可以使用类似的httpErrors元素来配置此行为web.config:
<system.webServer>
<httpErrors existingResponse="PassThrough"></httpErrors>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
请注意,配置它可能会对您的应用程序产生安全隐患.您可以在本文中阅读有关配置的更多信息httpErrors
| 归档时间: |
|
| 查看次数: |
2066 次 |
| 最近记录: |