mod_wsgi fails to log python errors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mod-wsgi (Ubuntu) |
Confirmed
|
Medium
|
Unassigned |
Bug Description
mod_wsgi based python apps that generate python errors, like divide by zero, should send a 500 error to the browser and log the python errors in the applications' log.
In Ubuntu 11.10 a regression was introduce where the Apache VirtualHost must be specified as *:80 for this expected behavior to still work. Anything else sends the 500 error to the browser, but leaves nothing in the apache log file.
Here are the 2 files needed to reproduce the problem...
To reproduce you also need an entry in /etc/hosts for www.hello.loc to be 127.0.0.1,
and an otherwise working apache server.
--- The standard mod_wsgi Hello World App, modifed to force a divide by zero error... ---
#!/usr/bin/python
def application(
a = 5/0 # This line added to induce a deliberate error. Hide this line to always see Hello World! in browser.
status = '200 OK'
output = 'Hello World!'
response_
start_
return [output]
--- The Apache Configuration file for this same application ---
WSGIRestrictEmb
<VirtualHost 127.0.0.1:80>
ServerName www.hello.loc
WSGIProcess
WSGIDaemonP
WSGIScriptAlias / /www/hello/
LogLevel warn
ErrorLog /www/hello/
CustomLog /www/hello/
</VirtualHost>
--- NOTES ---
The 2 files given above are SUPPOSED to generate an internal error to the browser (a 500 error)
AND log into the error log the python traceback showing the line and file where the divide by zero
error happened.
It does not work because of the 127.0.0.1 in the VirtualHost...
Also broke are Named Virtual Hosts of any form, as in...
<VirtualHost local>
The work around is to use "*" instead, as in...
<VirtualHost *:80>
I found this bug on an upgrade of Ubuntu Server to 11.10.
Note that the form that works, <VirtualHost *:80> serves the site on all IP addresses on a
server. This is the "toy" form of this command. Real servers are often multi-homed.
The parameter on the Virtual host when not *:80 is supposed to indicate the IP or named server that
is being used.
NOTE... ONLY ERROR LOGGING is impacted by this bug, NOT normal display.
A website impacted by this bug, especially after a system upgrade to 11.10, will serve
"Internal Server Errors" to client browsers and NOT log the error to the error logs
for discovery later by an administrator.
(As I found out to my trouble on a much, much bigger system than this example.)
Technically the work-around given above is a potential security issue depending on the networking
involved, so be careful if you're reading this and hacking your server to get it working again.
Changed in mod-wsgi (Ubuntu): | |
importance: | Undecided → Medium |
Status changed to 'Confirmed' because the bug affects multiple users.