【发布时间】:2014-08-08 16:32:13
【问题描述】:
我有一个在 Apache2 下运行的 mod_wsgi 应用程序,每当出现未捕获的异常时,都会显示默认的 Apache HTTP 500 错误页面,尽管我的 Apache 配置中有 ErrorDocument 500 /500.html。
是否有一些 mod_wsgi 指令可以用来显示我的自定义错误页面?我不是在寻找可以放在我的 mod_wsgi 脚本中的东西,因为如果脚本中有错误,那将无济于事。
编辑2:当使用下面的配置浏览到/cgi-bin/test.wsgi会成功显示自定义错误页面,但是浏览到/test会显示默认的Apache错误页面。
编辑:这是一个小示例配置,它给了我同样的问题:
/etc/apache2/sites-enabled/test
<VirtualHost *:80>
ServerName foo.example.com
DocumentRoot /path/to/docroot/
<Directory /path/to/docroot/>
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /path/to/docroot/cgi-bin/
<Directory /path/to/docroot/cgi-bin/>
Options +ExecCGI
AddHandler wsgi-script .wsgi
Order allow,deny
Allow from all
</Directory>
ErrorDocument 500 /500.html
WSGIDaemonProcess test user=www-data group=www-data processes=4 threads=1 display-name=%{GROUP}
WSGIProcessGroup test
</VirtualHost>
/path/to/docroot/.htaccess
RewriteEngine on
RewriteBase /
RewriteRule ^test/?$ /cgi-bin/test.wsgi/ [L,QSA]
/path/to/docroot/500.html
<html><body>This be 500.</body></html>
/path/to/docroot/cgi-bin/test.wsgi
hi
【问题讨论】: