After a very standard and minor release, our Apache/Nginx/Django/wsgi setup ceased to function with the only error "Premature end of script headers: django.wsgi" in the apache log.
There is no expat problem (checked with sample wsgi app with and without that module include). The server was working fine. The codebase was updated slightly and apache restarted when the horrors began. The codebase was rolled back and still the problem persists.
Below are my wsgi file, apache config and a dump from running wsgi under the debuger.
The system is Debian Squeeze, Apache/2.2.16 (Debian), Python 2.6.4, Django 1.3.1. modwsgi 3.3-2
All packages are installed via apt-get/pip. Another server with similar setup doesn't exhibit the problem.
(Pdb) request
<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': '6f41c55c934085b286fccb834e910643',
'sessionid': '58a6595013bf69a456a532b318446315',
'ys-account_id': 'n%3A585',
'ys-ad_preview_window-1332956': 'o%3Awidth%3Dn%253A532%5Eheight%3Dn%253A472%5Ex%3Dn%253A455%5Ey%3Dn%253A272',
'ys-client_id': 'n%3A202',
'ys-title': 's%3ASlots%20Farm%20-CA%205'},
META:{'DOCUMENT_ROOT': '/etc/apache2/htdocs',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.8,en;q=0.6',
'HTTP_CACHE_CONTROL': 'max-age=0',
'HTTP_CONNECTION': 'close',
'HTTP_COOKIE': 'ys-ad_preview_window-1332956=o%3Awidth%3Dn%253A532%5Eheight%3Dn%253A472%5Ex%3Dn%253A455%5Ey%3Dn%253A272; ys-account_id=n%3A585; ys-client_id=n%3A202; ys-title=s%3ASlots%20Farm%20-CA%205; csrftoken=6f41c55c934085b286fccb834e910643; sessionid=58a6595013bf69a456a532b318446315',
'HTTP_HOST': 'batman:8100',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11',
'HTTP_X_FORWARDED_FOR': '217.138.9.130',
'PATH_INFO': u'/',
'PATH_TRANSLATED': '/home/glowconsole/glowconsole/django.wsgi/',
'QUERY_STRING': '',
'REMOTE_ADDR': '81.94.195.18',
'REMOTE_PORT': '54800',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/',
'SCRIPT_FILENAME': '/home/glowconsole/glowconsole/django.wsgi',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '81.94.195.18',
'SERVER_ADMIN': 'harel at xxxxxx.com',
'SERVER_NAME': 'batman',
'SERVER_PORT': '8100',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SIGNATURE': '<address>Apache/2.2.16 (Debian) Server at batman Port 8100</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.16 (Debian)',
'mod_wsgi.application_group': 'theglowmachine.com:8100|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': 'batman',
'mod_wsgi.listener_port': '8100',
'mod_wsgi.process_group': '',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 3),
'wsgi.errors': <mod_wsgi.Log object at 0x7f4f886a7df0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f4f87277990>,
'wsgi.input': <mod_wsgi.Input object at 0x7f4f886a7db0>,
'wsgi.multiprocess': True,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 1)}>
(Pdb) locals()
{'start_response': <built-in method start_response of mod_wsgi.Adapter object at 0x7f4f87277990>, 'request': <WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': '6f41c55c934085b286fccb834e910643',
'sessionid': '58a6595013bf69a456a532b318446315',
'ys-account_id': 'n%3A585',
'ys-ad_preview_window-1332956': 'o%3Awidth%3Dn%253A532%5Eheight%3Dn%253A472%5Ex%3Dn%253A455%5Ey%3Dn%253A272',
'ys-client_id': 'n%3A202',
'ys-title': 's%3ASlots%20Farm%20-CA%205'},
META:{'DOCUMENT_ROOT': '/etc/apache2/htdocs',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.8,en;q=0.6',
'HTTP_CACHE_CONTROL': 'max-age=0',
'HTTP_CONNECTION': 'close',
'HTTP_COOKIE': 'ys-ad_preview_window-1332956=o%3Awidth%3Dn%253A532%5Eheight%3Dn%253A472%5Ex%3Dn%253A455%5Ey%3Dn%253A272; ys-account_id=n%3A585; ys-client_id=n%3A202; ys-title=s%3ASlots%20Farm%20-CA%205; csrftoken=6f41c55c934085b286fccb834e910643; sessionid=58a6595013bf69a456a532b318446315',
'HTTP_HOST': 'batman:8100',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11',
'HTTP_X_FORWARDED_FOR': '217.138.9.130',
'PATH_INFO': u'/',
'PATH_TRANSLATED': '/home/glowconsole/glowconsole/django.wsgi/',
'QUERY_STRING': '',
'REMOTE_ADDR': '81.94.195.18',
'REMOTE_PORT': '54800',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/',
'SCRIPT_FILENAME': '/home/glowconsole/glowconsole/django.wsgi',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '81.94.195.18',
'SERVER_ADMIN': 'harel @ xxxxx .com',
'SERVER_NAME': 'batman',
'SERVER_PORT': '8100',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SIGNATURE': '<address>Apache/2.2.16 (Debian) Server at batman Port 8100</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.16 (Debian)',
'mod_wsgi.application_group': 'theglowmachine.com:8100|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': 'batman',
'mod_wsgi.listener_port': '8100',
'mod_wsgi.process_group': '',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 3),
'wsgi.errors': <mod_wsgi.Log object at 0x7f4f886a7df0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f4f87277990>,
'wsgi.input': <mod_wsgi.Input object at 0x7f4f886a7db0>,
'wsgi.multiprocess': True,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http', 'wsgi.version': (1, 1)}>, 'self': <django.core.handlers.wsgi.WSGIHandler object at 0x7f4f886a7d90>, 'environ': {'mod_wsgi.listener_port': '8100', 'HTTP_COOKIE': 'ys-ad_preview_window-1332956=o%3Awidth%3Dn%253A532%5Eheight%3Dn%253A472%5Ex%3Dn%253A455%5Ey%3Dn%253A272; ys-account_id=n%3A585; ys-client_id=n%3A202; ys-title=s%3ASlots%20Farm%20-CA%205; csrftoken=6f41c55c934085b286fccb834e910643; sessionid=58a6595013bf69a456a532b318446315', 'mod_wsgi.listener_host': 'batman', 'SERVER_SOFTWARE': 'Apache/2.2.16 (Debian)', 'SCRIPT_NAME': u'', 'mod_wsgi.handler_script': '', 'SERVER_SIGNATURE': '<address>Apache/2.2.16 (Debian) Server at batman Port 8100</address>\n', 'REQUEST_METHOD': 'GET', 'PATH_INFO': u'/', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': '', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11', 'HTTP_CONNECTION': 'close', 'SERVER_NAME': 'batman', 'REMOTE_ADDR': '81.94.195.18', 'mod_wsgi.request_handler': 'wsgi-script', 'wsgi.url_scheme': 'http', 'PATH_TRANSLATED': '/home/glowconsole/glowconsole/django.wsgi/', 'SERVER_PORT': '8100', 'wsgi.multiprocess': True, 'mod_wsgi.input_chunked': '0', 'SERVER_ADDR': '81.94.195.18', 'DOCUMENT_ROOT': '/etc/apache2/htdocs', 'mod_wsgi.process_group': '', 'SCRIPT_FILENAME': '/home/glowconsole/glowconsole/django.wsgi', 'SERVER_ADMIN': 'harel at xxx.com', 'wsgi.input': <mod_wsgi.Input object at 0x7f4f886a7db0>, 'HTTP_HOST': 'batman:8100', 'wsgi.multithread': True, 'mod_wsgi.callable_object': 'application', 'HTTP_CACHE_CONTROL': 'max-age=0', 'REQUEST_URI': '/', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'wsgi.version': (1, 1), 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_X_FORWARDED_FOR': '217.138.9.130', 'wsgi.errors': <mod_wsgi.Log object at 0x7f4f886a7df0>, 'REMOTE_PORT': '54800', 'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.8,en;q=0.6', 'mod_wsgi.version': (3, 3), 'wsgi.run_once': False, 'mod_wsgi.application_group': 'theglowmachine.com:8100|', 'mod_wsgi.script_reloading': '1', 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f4f87277990>, 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch'}, 'settings': <django.conf.LazySettings object at 0x7f4f721f6a50>}