How to return an apache error page from a wsgi app?

删除回忆录丶 提交于 2020-01-01 06:36:26

问题


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.

For example, this works fine when my WSGI app crashes unintentionally, then I see the default 'internal server error' page from 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.

Any ideas?


回答1:


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

WSGIErrorOverride On

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

http://code.google.com/p/modwsgi/wiki/ChangesInVersion0300

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



来源:https://stackoverflow.com/questions/3691204/how-to-return-an-apache-error-page-from-a-wsgi-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!