The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Friday, July 08, 2005

Bugs in Apache

I think I found a bug in Apache 2.0.

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 is that I make use of Apache's mod_rewrite to make the external URLs decent. Also, because I want to handle errors correctly, I need to actually output the HTTP response header, so mod_blog uses a feature of Apache's mod_cgi that allows the CGI 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 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 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 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 …

Obligatory Picture

[The future's so bright, I gotta wear shades]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.