Ubuntu – Running nph-script.cgi keeps outputting Server details at the end

apache-2.2cgiperlUbuntu

I am running a nph-script.cgi on my server.

The server keeps adding

HTTP/1.1 200 OK Date: Thu, 05 Nov 2009
02:28:53 GMT Server: Apache/2.2.8
(Ubuntu) PHP/5.2.8-1hardy~ppa1 with
Suhosin-Patch mod_perl/2.0.3
Perl/v5.8.8 Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive Content-Type:
text/plain X-Pad: avoid browser bug

At the bottom of each page loaded via the .cgi script. why is this the case? How do I remove this annoying message that is appended to all pages ?

Best Answer

We are seeing a similar issue with an nph-file that acts as gateway to Intersystems Caché (a database and web application server). Works fine as long as we don't use URL rewriting. Any request handled by URL rewriting produces the spurious header described above (at or near the bottom of the response content).

We tried to isolate the bug with a small Perl nph-script and had the same problem. Tested on different servers: Apache/2.2.11 on Ubuntu 9.04, Apache/2.2.9 on Debian 5.0 and Apache/2.0.52 on Red Hat EL 4.

Script nph-test.cgi in regular cgi-bin directory:

#!/usr/bin/perl -wT
use strict;
print "$ENV{SERVER_PROTOCOL} 200 OK\n";
print "Server: $ENV{SERVER_SOFTWARE}\n";
print "Content-Type: text/plain\n\n";

# Tell Perl not to buffer our output
$| = 1;

print "OK.";

URL Rewriting

RewriteEngine On
RewriteRule ^test/([0-9]+)$ /cgi-bin/nph-test.cgi

(in Apache .conf file, under Directory /var/www/)

Response

OK.
HTTP/1.1 200 OK
Date: Mon, 07 Dec 2009 09:44:40 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch
Content-Length: 0
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/plain

Other sources describing the same or similar problems:

Using Content-Length works for the test-script, but doesn't solve our problem since we obviously can't change the nph-cgi executable that comes with Intersystems Caché.

As you say, this should probably be submitted to Apache, but the rules laid out at httpd.apache.org/bug_report.html are rather daunting. (I have limited knowledge of Apache.)