* * * * *

                                Bugs in Apache

I think I found a bug in Apache 2.0 [1].

I wanted to try a new look for the blog and while I have a test blog at home,
I can't really reach the webserver since it's behind the firewall web traffic
isn't forwarded, I thought it would be easier to get my blog running on my
workstation at The Office. I already have Apache 2.0 installed on the
machine, and getting the blog up and running only took a few minutes, even
including the time to make a few test entries.

Now, one of the things about mod_blog [2] is that I make use of Apache's
mod_rewrite [3] to make the external URL (Uniform Resource Locator)s decent.
Also, because I want to handle errors correctly, I need to actually output
the HTTP (HyperText Transport Protocol) response header, so mod_blog uses a
feature of Apache's mod_cgi [4] that allows the CGI (Common Gateway
Interface) to output the response code. So, within the Apache configuration I
have something like:

> RewriteEngine on
> RewriteBase   /
> RewriteRule   ^([0-9][0-9])(.*) nph-blog.cgi/$1$2 [L]
>

Basically, a URL of http://boston.conman.org/2005/07/08.1 [5] is, internally
to Apache, turned into http://boston.conman.org/nph-boston.cgi/2005/07/08.1
which does the actual parsing of the date to bring you the appropriate
entries (the nph- part of the name tells Apache not to generate any headers
for this script).

That works fine under Apache 1.3.

Under Apache 2.0, things are slightly different.

The same setup, and I get the page, but at the very bottom I get:

> HTTP/1.1 200 OK Date: Sat, 09 Jul 2005 05:44:15 GMT Server: Apache/2.0.54
> (Unix) DAV/2 PHP/4.3.11 Content-Length: 0 Connection: close Content-Type:
> text/plain
>

At first, I thought it might be a problem with mod_blog, since intially I had
the test blog as http://www.example.net/~spc/blog/ and that the problem could
be an interaction between Apache's mod_rewrite, mod_userdir [6] and mod_cgi
using a CGI script that generates the headers. Moving the blog to
http://www.example.net/ didn't improve things, so now it's down to an
interaction between mod_rewrite and mod_cgi and a CGI script that generates
the headers.

So, if I go to http://www.example.net/2005/07/08.1, I get the spurious
output, but if I go to http://www.example.net/nph-boston.cgi/2005/07/08.1 (go
through the CGI script directly) the page renders correctly and without the
extraneous stuff at the end.

I am running the latest version of Apache 2.0, and a rather quick query of
Google [7] didn't come up with any known issues with mod_cgi using “Non-
Header Parsing” scripts and mod_rewrite. Guess it's time to dig into the code


[1] http://httpd.apache.org/
[2] https://boston.conman.org/about/
[3] http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html
[4] http://httpd.apache.org/docs-2.0/mod/mod_cgi.html
[5] gopher://gopher.conman.org/0Phlog:2005/07/08.1
[6] http://httpd.apache.org/docs-2.0/mod/mod_userdir.html
[7] http://www.google.com/

Email author at [email protected]