如何从一个WSGI应用程序返回一个Apache错误页面? [英] How to return an apache error page from a wsgi app?

查看:284
本文介绍了如何从一个WSGI应用程序返回一个Apache错误页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的工作WSGI应用程序。我可以成功返回任何HTTP状态code,头文件和HTML我想要的。我想什么做的,就是当我返回一个状态code的其他的比'200 OK',对于WSGI让阿帕奇回落到其错误处理和显示任何网页阿帕奇被配置成根据其的ErrorDocument'设置以显示

I have a simple working wsgi app. I can successfully return whatever HTTP status code, headers, and HTML I want. What I would like to do, is that when I'm returning a status code other than '200 OK', for WSGI to let apache fall back to its error handling and display whatever page apache is configured to display according to its 'ErrorDocument' setting.

例如,这工作得很好,当我的WSGI应用程序崩溃无意中,我看到的apache默认的内部服务器错误页面。

For example, this works fine when my WSGI app crashes unintentionally, then I see the default 'internal server error' page from apache.

我的问题是,我怎么能做到这一点在受控的,故意的方式?例如,我就可以做我自己的身份验证,并退回到我已经设置了默认的Apache网页。

My question is, how can I do this in a controlled, deliberate manner? For example, I can then do my own authentication, and fallback to the default apache page I have set up.

任何想法?

推荐答案

presuming你居然用Apache下的mod_wsgi的意思是,请确保您正在使用的mod_wsgi daemon模式和设置:

Presuming you actually mean with mod_wsgi under Apache, ensure you are using mod_wsgi daemon mode and set:

WSGIErrorOverride On

有就是这mod_wsgi的3.0版发行说明简要提及。

There is a brief mention of this in mod_wsgi version 3.0 release notes.

HTTP://$c$c.google.com/p/ modwsgi /维基/ ChangesInVersion0300

如果您正在使用Apache作为在不同的Python的Web服务器前面的代理运行WSGI应用程序,然后使用Apache ProxyErrorOverride指令来代替。

If you are using Apache as proxy in front of distinct Python web server running WSGI application, then use Apache ProxyErrorOverride directive instead.

这篇关于如何从一个WSGI应用程序返回一个Apache错误页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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