Apache DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


HTTP Wrangler

Module Tour: mod_info

by Rael Dornfest
05/01/2000
  Module Tour Stops:

mod_info

mod_status

Apache's mod_info provides a snapshot of your server's current configuration.

We continue our module tour with a very brief gander at mod_info, another of my favorite Apache modules. Mod_info provides oodles of detailed configuration and module information for your server.

Splash!

Let's dive right in, shall we...

Apache Server Information

Server Settings, mod_php3.c, mod_jserv.c, mod_setenvif.c,
mod_so.c, mod_auth.c, mod_access.c, mod_alias.c, mod_userdir.c,
mod_actions.c, mod_imap.c, mod_asis.c, mod_cgi.c, mod_dir.c,
mod_autoindex.c, mod_include.c, mod_info.c, mod_status.c,
mod_negotiation.c, mod_mime.c, mod_log_config.c, mod_env.c,
http_core.c

Mod_info's output starts with a handy hyperlinked list of sections (corresponding to modules, mostly) in display-order, so the particular information you're after is only a click away.

Server Version: Apache/1.3.9 (Unix) ApacheJServ/1.1 PHP/3.0.12
Server Built: Dec 15 1999 10:53:22
API Version: 19990320:6
Run Mode: standalone
User/Group: nobody(1234)/1234
Hostname/port: www.mydomain.net:80
Daemons: start: 20    min idle: 25    max idle: 50    max: 256
Max Requests: per child: 10000
keep alive: on max per connection: 10000 Threads: per child: 0 Excess requests: per child: 0 Timeouts: connection: 300 keep-alive: 15 Server Root: /usr/local/apache Config File: conf/httpd.conf PID File: /usr/local/apache/logs/httpd.pid Scoreboard File: /usr/local/apache/logs/httpd.scoreboard

Next up is the Server Settings section, providing a rundown of your server's basic configuration. The first couple of lines identify our server as version 1.3.9 compiled on December 15th, 1999, with modules ApacheJserv and PHP. Almost everything else in this section is a mirror of configuration directives found in Apache's httpd.conf configuration file.

Module Name: mod_log_config.c 
Content handlers: none
Configuration Phase Participation: Create Server Config, 
     Merge Server Configs
Request Phase Participation: Logging
Module Directives: 
    CustomLog - a file name, a custom log format string or format name, 
     and an optional "env=" clause (see docs) 
    TransferLog - the filename of the access log 
    LogFormat - a log format string (see docs) and an optional format 
     name 
    CookieLog - the filename of the cookie log 
Current Configuration: 
httpd.conf 
    LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" 
     \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    CustomLog /usr/local/apache/logs/access_log combined

The layout of each module's section is standard; only the particulars change. Here I've grabbed mod_log_config's settings as an example. Module Name: displays (surprise!) the name of the module at hand -- actually, the name of the C source file from which this module is built.

Content handlers are one or more actions to be taken by the server when a file is called. While most files are simply heated and served by Apache without much in the way of futzing, some need to be handled in a particular way. Mod_info, for example, uses a server-info handler, defined in the mod_info.c module source. Its Content handlers output looks like:

Content handlers: server-info 

Apache knows about this handler via the SetHandler server-info runtime configuration directive described in the Configuration section below. For more information on Apache's handler use, point your browser at Apache.org's appropriately named Apache's Handler Use page.

The Configuration Phase Participation and Request Phase Participation represent the various configuration and request phases in which this module is involved. Our example, mod_log_config, is involved in the logging phase of each request. For more detail on the various stages of configuration and requests than you can shake a stick at, take a gander at Apache.org's Apache API notes page.

Module Directives are (gasp!) descriptions of the configuration directives associated with this module. This is a nice little cheat sheet; if, however, you require more detail, visit Apache modules for details for each of the modules shipped with Apache, and Apache Directives.

Finally we arrive at the actual configuration directives found in your server's current httpd.conf configuration file. If you're familiar with Apache logfile configuration, you should recognize the LogFormat and CustomLog directives.

Core Configuration

Be sure to visit the http_core.c section at the very bottom of mod_info's page. It is here that you'll find all of your server's non-module-specific configuration directives.

Module Name: http_core.c 
Content handlers: */* , default-handler
Configuration Phase Participation: Create Directory Config, 
     Merge Directory Configs, Create Server Config, Merge Server 
     Configs
Request Phase Participation: Translate Path, Check Access, 
     Check Type
Module Directives: 
     <Directory> - Container for directives affecting resources located 
     in the specified directories 
     </Directory> - Marks end of 
     <Location> - Container for directives affecting resources accessed 
     through the specified URL paths
[several miles later]
LimitRequestBody - Limit (in bytes) on maximum size of request 
     message body 
Current Configuration: 
httpd.conf
     ServerType standalone
     ServerRoot "/usr/local/apache"
     PidFile /usr/local/apache/logs/httpd.pid
[and so on...]

Installation

So how do you install mod_info? Installation of the standard Apache modules is, well, standard. Follow the directions in the Installation section of my previous HTTP Wrangler column, Module Tour: mod_status. Simply replace each mention of --enable-module=status with --enable-module=info. Once installed, come on back for the quickest module configuration this side of El Paso.

Configuration

As with the status module, mod_info is simple to configure; in fact the directives already exist in your httpd.conf file and simply need to be uncommented and edited slightly. If you're not familiar with Apache configuration, may I suggest you read my earlier HTTP Wrangler column, An Amble Through Apache Configuration.

# cd /usr/local/apache/conf

(or wherever your Apache installation's configuration files are located.)

Open your httpd.conf file in the text editor of your choice and search for the following set of configuration directives:

#
# Allow remote server configuration reports, with the URL of
#  http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".your_domain.com" to match your domain to enable.
#
#<Location /server-info>
#    SetHandler server-info
#    Order deny,allow
#    Deny from all
#    Allow from .your_domain.com
#</Location>

Uncomment everything from <Location /server-info> to </Location> by removing the # characters from the beginning of each line.

It's wise to protect your server-info output from prying eyes. The easiest way to do this is to restrict its access to one computer or domain. Change the .your_domain.com to the name of a computer or domain you wish to allow a peek at server-info. For example, if you're the webmaven for your server, you may want to allow access only from your computer, mycomputer.mydomain.org. Your server-info configuration would look something like:

#
# Allow remote server configuration reports, with the URL of
#  http://servername/server-info (requires that mod_info.c be loaded).
# Change the .your_domain.com to match your domain to enable.
#
<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from mycomputer.mydomain.org
</Location>

That's all there is to mod_info configuration. Save your httpd.conf file, shut down and start Apache.

# /usr/local/apache/sbin/apachectl stop
/usr/local/apache/sbin/apachectl stop: httpd stopped
# /usr/local/apache/sbin/apachectl start
/usr/local/apache/sbin/apachectl start: httpd started
#

Fire up your Web browser on a machine allowed access to your server's server-info and point it at the URL:

http://servername/server-info

That's all she wrote! For more information on mod_info and other aspects of Apache we touched on along the way, visit the Resources section below.


Resources

The following is a list of starting points from which to explore further some of the topics covered (or not) in this article.

Suggestions?

As always, if you'd like us to cover anything in particular, feel free to post your suggestions to the O'Reilly Network Apache Forum.

Rael Dornfest is Founder and CEO of Portland, Oregon-based Values of n. Rael leads the Values of n charge with passion, unearthly creativity, and a repertoire of puns and jokes — some of which are actually good. Prior to founding Values of n, he was O'Reilly's Chief Technical Officer, program chair for the O'Reilly Emerging Technology Conference (which he continues to chair), series editor of the bestselling Hacks book series, and instigator of O'Reilly's Rough Cuts early access program. He built Meerkat, the first web-based feed aggregator, was champion and co-author of the RSS 1.0 specification, and has written and contributed to six O'Reilly books. Rael's programmatic pride and joy is the nimble, open source blogging application Blosxom, the principles of which you'll find in the Values of n philosophy and embodied in Stikkit: Little yellow notes that think.

Read more HTTP Wrangler columns.


Return to the Apache DevCenter.





Sponsored by: