ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


A Day in the Life of #Apache
Or, Why I Hate the Apache Web Server

by Rich Bowen, coauthor of Apache Cookbook
09/08/2005

Editor's note: Rich Bowen is back with another installment in his occasional series based on conversations on #apache. In this article, Rich discusses a particular Apache Web Server annoyance--the Options directive--and he explains how it works and why it does what it does. Rich is a coauthor of O'Reilly's Apache Cookbook.

#apache is an IRC channel that runs on the irc.freenode.net IRC network. To join this channel, you need to install an IRC client (XChat, MIRC, and bitchx are popular clients) and enter the following commands:

/server
irc.freenode.net
/join #apache

Day Thirteen

This July, at ApacheCon Europe in Stuttgart, I gave a "Lightning" talk entitled, "Why I Hate the Apache Web Server." The talk contained a lot of things that generally cause irritation on the Apache Web Server. Many of these things need further explanation because, since it was a lightning talk, I only had 5 minutes.

Most of the things covered in the talk were things that come up every day on #apache, and so they are perfect for this series of articles. For the next few installments, I'm going to pick and choose among the things that I was complaining about, but you can see the whole presentation at people.apache.org/~rbowen/presentations/apacheconEU2005/hate_apache.pdf.

Today, we'll start by investigating my first complaint, which has to do with the Options directive. Consider the following two examples (taken from the slide presentation):

  Options +Indexes Includes MultiViews
  Options  Indexes Includes Multiviews

Now, these two examples appear almost identical, and it would appear that they should do the same thing. However, they don't. Strangely, the first line disables Indexes, and enables Includes and Multiviews. The second line does what you might more expect; that is, it enables Indexes, Includes, and Multiviews.

One is somewhat torn, at this point, between explaining why it does it that way, and simply explaining how to avoid the problem in the first place. So, we'll do both.

First, the practical question: How can I avoid this problem entirely. Don't mix the +/- syntax with bareword syntax. That is, when using Options, either all items in the list should be prefixed with a + or a -, or none of them should. If you mix, then you're going to have problems.

Now, the more difficult task--explaining how this is supposed to work, and why it does what it does.

The Options directive has the +/- syntax, which appears in a few other directives, such as IndexOptions. There are two possible ways to use the Options directive, as well as the third way, which doesn't work.

When you list a series of Options without modifying them with a + or a - sign, the behavior is to use that as the new list of options. That is, whatever other options are already in place are cleared, and the new list is used instead. For example, if we have:

    Options Indexes
    Options Includes

The documented (and actual) result is that only the Includes option will be enabled. The second Options directive has the effect of completely resetting the existing list (which was Indexes) and replacing it with the new list.

The +/- syntax, on the other hand, has the effect of adding to, or removing from, the existing list. Thus, in this example:

    Options Indexes
    Options +Includes

The result is that Indexes and Includes are both in effect.

Similarly with the - (minus sign) the specified options are removed from the existing list.

The difficulty comes when you attempt to mix these two syntaxes in the same listing. Thus, we come to the example that we started with:

    Options +Indexes Includes MultiViews

So, by the rules above, the Indexes option is added to whatever was already in place, by virtue of the + notation. However, when we get to the Includes option, since there's no + or - sign, the list is cleared, and the remaining options (Includes and Multiviews) are set as the new list. Thus, although by casual inspection it seems that we should end up with all three options turned on, only the last two are in fact turned on.

That's all well and good, except that it is completely unexpected by the user. And, to further complicate things, this isn't necessarily consistent. For example, if you do:

    Options Includes +Indexes Multiviews

it turns out that Indexes is in fact enabled. This seems to contradict the long explanation I just went through.

The real answer to this problem is that you should never ever mix the +/- and bareword syntaxes. The results are too unpredictable unless you actually delve into the code and figure out what it's doing. But even when you do that, it's not clear what you should do about it.

If, for example, someone used the following syntax:

    Options Indexes
    Options Includes +ExecCGI

What do you think they meant?

Yeah, I don't know either. Better to just yell at them for using invalid syntax, and force them to go fix it.

There's one small problem with that approach, and that's that a number of third-party distributions of Apache, like several Linux distrubutions, ship default configuration files using syntax like this, and they expect it to work. Making it break would make a lot of people very unhappy. However, that might just be a necessary tradeoff.

Just in case you missed the goal of either the presentation I gave at ApacheCon (and again at OSCON), or of this series of articles, I want to take this opportunity to state it clearly. It's not just to complain. If it was that, it would be little more than petty whining and a waste of your time.

The purpose is to point out areas where you, the interested contributor, can focus your efforts, if you're looking for a place where you can plug in. Every one of the issues I addressed has a solution, and some of them are fairly simple.

The other purpose is (as stated in the initial slide), to let the core group of developers know what is irritating their users. You'll be happy to know that they received this very warmly, and that a number of the problems have already been fixed since the talk was presented. It's not the traditional way to submit bug reports, but it was very effective.

Rich Bowen is a member of the Apache Software Foundation, working primarily on the documentation for the Apache Web Server. DrBacchus, Rich's handle on IRC, can be found on the web at www.drbacchus.com/journal.


Return to the Apache DevCenter

Copyright © 2009 O'Reilly Media, Inc.