Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Apache Modules

Apache is built upon a modular concept. At its core there is little functionality. Modules are added in order to implement more advanced features and functionality. Each module solves a well-defined problem by adding the extra features that are needed. Using this concept, you can more or less tailor Apache server to suit your exact needs.

There are close to 40 modules included with the basic Apache server. Many more are available from other developers. There is a repository for add-on modules for Apache called The Apache Module Registry, and it can be found at http://modules.apache.org/.

Each module adds new directives that can be used in your configuration files. As you might guess, there are far too many extra commands, switches, and options to describe them all in this chapter. Therefore, this section will only briefly describe those modules that are available with Red Hat's Apache installation. If you need further information on how to use a module, please refer to the online documentation for the server that is included with the Red Hat distribution or look at the Apache Groups Web site. Local copies of this documentation are located at http://localhost/manual/.

Following is an alphabetical list of those modules that are included with Red Hat's Apache RPM.

mod_access

This module gives you the ability to control access to areas on your Web server based on IP addresses, hostnames, and/or environment variables. You will be able to grant or deny access to any part of your Web server depending on those criteria. It is possible to use partial hostnames or subsets of IP addresses as access qualifiers. For example, you might want to allow anyone from within your own domain to access certain areas of your Web. See the section Authentication and Access Control for more information.

mod_actions

This module provides the ability to dynamically execute scripts based on the type of HTTP request. You will be able to map the execution of CGI scripts to MIME content types or request methods.

mod_alias

There are times when you need to manipulate the URLs of incoming HTTP requests. You might want to redirect the client's request to another URL, or you may want to map a part of the filesystem into your Web hierarchy. For example:

Alias /images/ /home/wsb/graphics/

This example would fetch contents from the /home/wsb/graphics directory for any URL that starts with /images/. This will be done without the client knowing anything about it. If you use a redirection, the client will be instructed to go to another URL to find the requested content.

For more advanced URL manipulation, look at mod_rewrite also.

mod_asis

Using this module you will be able to specify in fine detail all information that is to be included in a response. This will completely bypass any headers that Apache might otherwise have added to the response. All files with an .asis extension will be sent straight through to the client without any changes.

As a short example, assume that you have moved the contents from one location to another on your site. Now you need to inform people who try to access this resource that it has moved, as well as redirect them to the new location automatically. To do this you might add something like the following code into a file with an .asis extension.

Status: 301 No more old stuff!
Location: http://gnulix.org/newstuff/
Content-type: text/html

<HTML>
 <HEAD>
  <TITLE>We've moved...</TITLE>
 </HEAD>
 <BODY>
   <P>We've moved the old stuff and now you'll find it at:</P>
   <A HREF="http://gnulix.org/newstuff/">New stuff</A>!.
 </BODY>
</HTML>
					
					
				

mod_auth

This is the simplest of all user authentication schemes available for Apache, and as such it is often referred to as Basic authentication. This scheme is based on storing usernames and encrypted passwords in a text file. This file looks very much like UNIX's /etc/passwd file. These files are created with the htpasswd command. See the section Authentication and Access Control for more information about this subject.

mod_auth_anon

This module provides anonymous authentication similar to that of anonymous FTP. The module will allow you to define user IDs of those who are to be handled as guest users. When such a user tries to log on, she will be prompted for her email address as her password. It is possible to have Apache check the password to ensure that it is a (more or less) proper email address. Basically it ensures that there is an @ character and at least one . character in the password.

mod_auth_db

This module is very much like the mod_auth module. Rather than keeping the user data in a plain text file it uses Berkeley DB files.

mod_auth_digest

This is an extension of the basic mod_auth module. Instead of sending the user information in plain text it will be sent via the MD5 Digest Authentication process. This authentication scheme is defined in RFC 2617. This is a much more secure way of sending user data over the Internet compared to using Basic authentication. Unfortunately, not all Web browsers support this authentication scheme.

To create password files for use with mod_auth_dbm you will need to use the htdigest utility. It has more or less the same functionality as the htpasswd utility. See the man page of htdigest for further information.

mod_autoindex

If you have not provided a default HTML file for a directory and have enabled directory indexing, this module will dynamically create a file list for the directory in question. This list will be rendered in a user-friendly manner similar to those lists that FTP provides. There are many options that will provide you with the ability to fine-tune every aspect of the look and feel of the directory listing.

mod_bandwidth

This module provides bandwidth usage limitation. It enables basic traffic shaping for replies so that the server will not become overloaded when there are too many requests. This can be applied either to parts of the server or the whole server. You may apply the module based on file size, location or domain of the client, and the location or directory of the requested material.

This is one of the third-party modules that Red Hat has added that are generally not part of the Apache distribution.

mod_cern_meta

This module gives you the ability to add additional HTTP headers to each HTTP response. You can configure Apache so that the contents of files with certain extensions, usually .meta, will be included together with any other HTTP headers that Apache generates.

mod_cgi

This module allows you to execute CGI scripts on you server. See the section on dynamic content for more information about how to use CGIs.

mod_digest

This module is being deprecated and will be replaced by mod_auth_digest. Therefore, you are probably better off using that module instead.

mod_dir

This is used to determine which files are returned automatically when a user tries to access a directory. The default is index.html. If you have users who create Web pages on Windows systems you will probably want to include index.htm as well like this:

DirectoryIndex index.html index.htm

mod_env

This module allows you to control how environment variables are passed to CGI and SSI scripts.

mod_example

This is only a demo module. Its main purpose is for people to study its source code and learn how to code new modules for Apache.

mod_expires

Use this module if you want to add an expire date to content on your site. This is accomplished by adding an Expires header to the HTTP response. Content that has expired will not be cached by Web browsers or cache servers.

mod_headers

This is a very useful module that allows you to manipulate the HTTP headers of your server's responses. You can replace, add, merge, or delete headers as you see fit. The module supplies a directive for this called Header. Ordering of the Header directive is important. A set followed by an unset for the same HTTP header will remove the header altogether. You can place Header directives almost anywhere within your configuration files. These directives are then processed in the following order:

  1. Core Server
  2. Virtual Host
  3. <Directory> and .htaccess files
  4. <Location>
  5. <Files>

mod_imap

This module provides for server-side handling of image map files. Clickable regions are defined in a .map file. There are six directives available for use in the .map file. These are used to describe the layout of the clickable regions as well as which URLs they lead to.

mod_include

This enables the use of Server-Side Includes on your server. See the section Dynamic Content later in the chapter for more information about how to use SSI.

mod_info

The mod_info module provides comprehensive information about your server's configuration. For example, it will display all the modules that are installed, as well as all the directives that are used in its configuration files.

mod_log_agent

This enables you to log the content of the UserAgent header from HTTP requests. Using this information allows you to see which Web browsers visitors to your site are using.

mod_log_config

This module allows you to define how your log files should look. See the section Logging for further information about this subject.

mod_log_referer

This enables you to log the referer part of an HTTP request.

mod_mime

This module tries to determine the MIME type of files from their extensions.

mod_mime_magic

This module tries to determine the MIME type of files by examining portions of their content.

mod_mmap_static

This module uses the mmap() function to map static pages into system memory. This is used to reduce the server latency introduced by disk access. Because these pages are cached within system memory, the server will need to be restarted if the pages are updated on disk.

mod_negotiation

Using this module it is possible to select one of several document versions that best suits the client's capabilities. There are several options to select which criteria to use in the negotiation process. You can, for example, choose among different languages, graphics file formats, and compression methods.

mod_proxy

This module implements proxy and caching capabilities for an Apache server. It can proxy and cache FTP, CONNECT, HTTP/0.9, and HTTP/1.0 requests. This is not an ideal solution for sites that have a large number of users and therefore have very high proxy and cache requirements. However, it is more than adequate for a small number of users.

mod_put

This module implements the PUT and DELETE methods from the HTTP/1.1 protocol.

This is one of the third-party modules that Red Hat has added. These are generally not part of the Apache distribution.

mod_rewrite

This is the Swiss army knife of URL manipulation. It allows you to perform any imaginable manipulation of URLs using powerful regular expressions. It provides rewrites, redirection, proxying, and so on. There is very little that you connot accomplish using this module.

See http://localhost/manual/misc/rewriteguide.html for a cookbook, which will give you a very good overview of what this module is capable of.

mod_setenvif

This module allows you to manipulate environment variables. Using regular expressions it is possible to conditionally change the content of environment variables. The order in which SetEnvIf directives appear in the configuration files is important. It is possible that each SetEnvIf directive may reset an earlier SetEnvIf directive when used on the same environment variable. Be sure to keep that in mind when using the directives from this module.

mod_speling

This module automatically corrects minor typos in URLs. If no file matches the requested URL, this module will build a list of the files in the requested directory and will extract those files that are the closest matches. It will try to correct only one spelling mistake.

mod_status

This module creates a Web page containing a plethora of information about a running Apache server. The page will contain information about the internal status as well as statistics about the running Apache processes. This can be a great aid when you are trying to configure your server for maximum performance. It is also a good indicator when something is amiss with your Apache server.

mod_throttle

This module provides you with the possibility to throttle incoming requests so that the server will not become overloaded when there are too many requests. You may throttle requests directed either to a certain user's material or to a specific virtual host.

You can access the documentation for this module at http://www.snert.com/software/throttle/.

This is one of the third-party modules that Red Hat has added. These are generally not part of the Apache distribution.

mod_unique_id

This module generates a unique request identifier for every incoming request. This ID will be put into the UNIQUE_ID environment variable.

mod_userdir

This module enables you to map a subdirectory in each user's home directory into your Web tree. The module provides several different ways to accomplish this.

mod_usertrack

This module generates a cookie for each user session. This can be used to track the user's click stream within your Web tree. You will need to enable a custom log that logs this cookie into a log file.

mod_vhost_alias

This module provides excellent support for dynamically configured mass virtual hosting. It is especially useful for ISPs with very many virtual hosts. However, for the average user Apache's ordinary virtual hosting support should prove to be more than sufficient.

There are two ways to host virtual hosts on an Apache server. You can either have one IP address with multiple CNAMEs, or you can have multiple IP addresses with one name per address. Apache has different sets of directives to handle each of these options.

Share ThisShare This

Informit Network