cgitb weirdness between apache and nginx

Robin Becker robin at reportlab.com
Mon Jul 3 05:22:40 EDT 2017


I have a simple cgi application and want to use cgitb as a catchall way of 
getting an error response when things go wrong

I did development with nginx + fastcgi + fsgiwrap and the cgitb failure output 
appears to work fine.

The end user wants to use apache 2.4 and there things go wrong. Instead of the 
cgitb traceback html I am seeing a generic apache server error page.

After some serious debugging with strace I find that the cgitb is starting to 
write, but it appears that it always starts writing something containing the 
word spam eg

<!--: spam
Content-Type: text/html

<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> -->
<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> -->
</font> </font> </font> </script> </object> </blockquote> </pre>
</table> </table> </table> </table> </table> </font> </font> </font><body 
bgcolor="#f0f0f8">


this is from the function reset in cgitb.

My application has not written anything at the point this appears and it seems 
that apache just considers this an erroneous output. In order to make apache 
behave it seems I must start stdout before an error has occurred. That appears 
silly when I don't know when an error will occur.

Is there a way to get cgitb to check whether anything has been written to stdout 
when it starts up? Or is there some standard way to initialize stdout so that 
cgitb will not force apache to the wrong conclusion?
-- 
Robin Becker




More information about the Python-list mailing list