Public bug reported: 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(environ, start_response): 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_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output] --- The Apache Configuration file for this same application --- WSGIRestrictEmbedded On <VirtualHost 127.0.0.1:80> ServerName www.hello.loc WSGIProcessGroup hello.loc WSGIDaemonProcess hello.loc processes=1 threads=10 display-name=%{GROUP} WSGIScriptAlias / /www/hello/website.py process-group=hello.loc application-group=${GLOBAL} LogLevel warn ErrorLog /www/hello/logs/error.log CustomLog /www/hello/logs/access.log combined </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. ** Affects: mod-wsgi (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to mod-wsgi in Ubuntu. https://bugs.launchpad.net/bugs/908605 Title: mod_wsgi fails to log python errors To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/mod-wsgi/+bug/908605/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs