From 07050bb5be522bbf66bb8f053b53beefa295ee68 Mon Sep 17 00:00:00 2001
From: Ken Coar
+responds to different IP addresses, hostnames and ports.
There are two directives used to restrict or specify which addresses
and ports Apache listens to.
-
+
Makes the server listen to just the specified address. If the argument
is *, the server listens to all addresses. The port listened to
-is set with the Port directive. Only one BindAddress
+is set with the Port directive. Only one BindAddress
should be used.
-
+
-Listen can be used instead of BindAddress and
-Port. It tells the server to accept incoming requests on the
+Listen can be used instead of BindAddress and
+Port. It tells the server to accept incoming requests on the
specified port or address-and-port combination. If the first format is
used, with a port number only, the server listens to the given port on
-all interfaces, instead of the port given by the Port
+all interfaces, instead of the port given by the Port
directive. If an IP address is given as well as a port, the server
-will listen on the given port and interface. Multiple Listen
+will listen on the given port and interface. Multiple Listen
directives may be used to specify a number of addresses and ports to
listen to. The server will respond to requests from any of the listed
-addresses and ports.
+addresses and ports.
For example, to make the server accept connections on both port
80 and port 8000, use:
-
+responds to different IP addresses, hostnames and ports.
There are two directives used to restrict or specify which addresses
and ports Apache listens to.
-
+
Makes the server listen to just the specified address. If the argument
is *, the server listens to all addresses. The port listened to
-is set with the Port directive. Only one BindAddress
+is set with the Port directive. Only one BindAddress
should be used.
-
+
-Listen can be used instead of BindAddress and
-Port. It tells the server to accept incoming requests on the
+Listen can be used instead of BindAddress and
+Port. It tells the server to accept incoming requests on the
specified port or address-and-port combination. If the first format is
used, with a port number only, the server listens to the given port on
-all interfaces, instead of the port given by the Port
+all interfaces, instead of the port given by the Port
directive. If an IP address is given as well as a port, the server
-will listen on the given port and interface. Multiple Listen
+will listen on the given port and interface. Multiple Listen
directives may be used to specify a number of addresses and ports to
listen to. The server will respond to requests from any of the listed
-addresses and ports.
+addresses and ports.
For example, to make the server accept connections on both port
80 and port 8000, use:
- As implemented in Apache 1.1.1 and earlier versions, the method
+ As implemented in Apache 1.1.1 and earlier versions, the method
Apache used to create PATH_INFO in the CGI environment was
counterintuitive, and could result in crashes in certain cases. In
Apache 1.2 and beyond, this behavior has changed. Although this
results in some compatibility problems with certain legacy CGI
applications, the Apache 1.2 behavior is still compatible with the
-CGI/1.1 specification, and CGI scripts can be easily modified (see below).
+CGI/1.1 specification, and CGI scripts can be easily modified (see below).
- Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME
+ Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME
environment variables by looking at the filename, not the URL. While
this resulted in the correct values in many cases, when the filesystem
path was overloaded to contain path information, it could result in
errant behavior. For example, if the following appeared in a config
file:
- In this case, In this case, Setting which addresses and ports Apache uses
+Setting which addresses and ports Apache uses
-
+
When Apache starts, it connects to some port and address on the
local machine and waits for incoming requests. By default, it
listens to all addresses on the machine, and to the port
-as specified by the Port directive in the server configuration.
+as specified by the Port directive in the server configuration.
However, it can be told to listen to more the one port, or to listen
to only selected addresses, or a combination. This is often combined
with the Virtual Host feature which determines how Apache
-responds to different IP addresses, hostnames and ports.
-
-
+
+BindAddress
-Syntax: BindAddress [ * | IP-address | hostname ]
-Default: BindAddress *
-Context: server config
-Status: CoreBindAddress
+Syntax: BindAddress [ * | IP-address | hostname ]
+Default: BindAddress *
+Context: server config
+Status: CoreListen
-Syntax: Listen [ port | IP-address:port ]
-Default: none
-Context: server config
-Status: CoreListen
+Syntax: Listen [ port | IP-address:port ]
+Default: none
+Context: server config
+Status: Core
+
To make the server accept connections on two specified
interfaces and port numbers, use
-
Listen 80
Listen 8000
-
+
+
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
-
+How this works with Virtual Hosts
@@ -95,12 +95,12 @@ not listening to, it cannot be accessed.
See also
See also the documentation on
-Virtual Hosts,
-BindAddress directive,
-Port directive,
-DNS Issues
+Virtual Hosts,
+BindAddress directive,
+Port directive,
+DNS Issues
and
-<VirtualHost> section.
+<VirtualHost> section.
diff --git a/docs/manual/bind.html.en b/docs/manual/bind.html.en
index 2398082a14..3b31b437a2 100644
--- a/docs/manual/bind.html.en
+++ b/docs/manual/bind.html.en
@@ -1,7 +1,7 @@
-
-Setting which addresses and ports Apache uses
+Setting which addresses and ports Apache uses
-
+
When Apache starts, it connects to some port and address on the
local machine and waits for incoming requests. By default, it
listens to all addresses on the machine, and to the port
-as specified by the Port directive in the server configuration.
+as specified by the Port directive in the server configuration.
However, it can be told to listen to more the one port, or to listen
to only selected addresses, or a combination. This is often combined
with the Virtual Host feature which determines how Apache
-responds to different IP addresses, hostnames and ports.
-
-
+
+BindAddress
-Syntax: BindAddress [ * | IP-address | hostname ]
-Default: BindAddress *
-Context: server config
-Status: CoreBindAddress
+Syntax: BindAddress [ * | IP-address | hostname ]
+Default: BindAddress *
+Context: server config
+Status: CoreListen
-Syntax: Listen [ port | IP-address:port ]
-Default: none
-Context: server config
-Status: CoreListen
+Syntax: Listen [ port | IP-address:port ]
+Default: none
+Context: server config
+Status: Core
+
To make the server accept connections on two specified
interfaces and port numbers, use
-
Listen 80
Listen 8000
-
+
+
Listen 192.170.2.1:80
Listen 192.170.2.5:8000
-
+How this works with Virtual Hosts
@@ -95,12 +95,12 @@ not listening to, it cannot be accessed.
See also
See also the documentation on
-Virtual Hosts,
-BindAddress directive,
-Port directive,
-DNS Issues
+Virtual Hosts,
+BindAddress directive,
+Port directive,
+DNS Issues
and
-<VirtualHost> section.
+<VirtualHost> section.
diff --git a/docs/manual/cgi_path.html b/docs/manual/cgi_path.html
index 8ac3bc0dd1..ed95efcd42 100644
--- a/docs/manual/cgi_path.html
+++ b/docs/manual/cgi_path.html
@@ -1,7 +1,7 @@
-
-PATH_INFO Changes in the CGI Environment
+PATH_INFO Changes in the CGI Environment
-
+
-Overview
+Overview
-The Problem
+The Problem
-
+
+
Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph
-
-user.cgi
is the CGI script, the "/ralph"
+user.cgi
is the CGI script, the "/ralph"
is information to be passed onto the CGI. If this configuration was in
-place, and a request came for "/cgi-ralph/script/
", the
-code would set PATH_INFO to "/ralph/script
", and
-SCRIPT_NAME to "/cgi-
". Obviously, the latter is
+place, and a request came for "/cgi-ralph/script/
", the
+code would set PATH_INFO to "/ralph/script
", and
+SCRIPT_NAME to "/cgi-
". Obviously, the latter is
incorrect. In certain cases, this could even cause the server to
-crash.
Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO by +
Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO by
looking directly at the URL, and determining how much of the URL is
client-modifiable, and setting PATH_INFO to it. To use the above
-example, PATH_INFO would be set to "/script
", and
-SCRIPT_NAME to "/cgi-ralph
". This makes sense and results
+example, PATH_INFO would be set to "/script
", and
+SCRIPT_NAME to "/cgi-ralph
". This makes sense and results
in no server behavior problems. It also permits the script to be
guaranteed that
-"http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO
"
+"http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO
"
will always be an accessible URL that points to the current script,
something which was not necessarily true with previous versions of
Apache.
-
However, the "/ralph
"
-information from the Alias
directive is lost. This is
+
However, the "/ralph
"
+information from the Alias
directive is lost. This is
unfortunate, but we feel that using the filesystem to pass along this
sort of information is not a recommended method, and a script making
use of it "deserves" not to work. Apache 1.2b3 and later, however, do
-provide a workaround.
+provide a workaround.
-
It may be necessary for a script that was designed for earlier +
It may be necessary for a script that was designed for earlier versions of Apache or other servers to need the information that the old PATH_INFO variable provided. For this purpose, Apache 1.2 (1.2b3 and later) sets an additional variable, FILEPATH_INFO. This environment variable contains the value that PATH_INFO would have had -with Apache 1.1.1.
+with Apache 1.1.1. -A script that wishes to work with both Apache 1.2 and earlier +
A script that wishes to work with both Apache 1.2 and earlier versions can simply test for the existence of FILEPATH_INFO, and use it if available. Otherwise, it can use PATH_INFO. For example, in Perl, one might use: -
+-$path_info = $ENV{'FILEPATH_INFO'} || $ENV{'PATH_INFO'}; -+
By doing this, a script can work with all servers supporting the -CGI/1.1 specification, including all versions of Apache.
+By doing this, a script can work with all servers supporting the +CGI/1.1 specification, including all versions of Apache.
diff --git a/docs/manual/cgi_path.html.en b/docs/manual/cgi_path.html.en index 8ac3bc0dd1..ed95efcd42 100644 --- a/docs/manual/cgi_path.html.en +++ b/docs/manual/cgi_path.html.en @@ -1,7 +1,7 @@ - -As implemented in Apache 1.1.1 and earlier versions, the method +
As implemented in Apache 1.1.1 and earlier versions, the method Apache used to create PATH_INFO in the CGI environment was counterintuitive, and could result in crashes in certain cases. In Apache 1.2 and beyond, this behavior has changed. Although this results in some compatibility problems with certain legacy CGI applications, the Apache 1.2 behavior is still compatible with the -CGI/1.1 specification, and CGI scripts can be easily modified (see below). +CGI/1.1 specification, and CGI scripts can be easily modified (see below). -
Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME +
Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME environment variables by looking at the filename, not the URL. While this resulted in the correct values in many cases, when the filesystem path was overloaded to contain path information, it could result in errant behavior. For example, if the following appeared in a config file: -
++Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph --In this case,
user.cgi
is the CGI script, the "/ralph" +
In this case, user.cgi
is the CGI script, the "/ralph"
is information to be passed onto the CGI. If this configuration was in
-place, and a request came for "/cgi-ralph/script/
", the
-code would set PATH_INFO to "/ralph/script
", and
-SCRIPT_NAME to "/cgi-
". Obviously, the latter is
+place, and a request came for "/cgi-ralph/script/
", the
+code would set PATH_INFO to "/ralph/script
", and
+SCRIPT_NAME to "/cgi-
". Obviously, the latter is
incorrect. In certain cases, this could even cause the server to
-crash.
Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO by +
Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO by
looking directly at the URL, and determining how much of the URL is
client-modifiable, and setting PATH_INFO to it. To use the above
-example, PATH_INFO would be set to "/script
", and
-SCRIPT_NAME to "/cgi-ralph
". This makes sense and results
+example, PATH_INFO would be set to "/script
", and
+SCRIPT_NAME to "/cgi-ralph
". This makes sense and results
in no server behavior problems. It also permits the script to be
guaranteed that
-"http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO
"
+"http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO
"
will always be an accessible URL that points to the current script,
something which was not necessarily true with previous versions of
Apache.
-
However, the "/ralph
"
-information from the Alias
directive is lost. This is
+
However, the "/ralph
"
+information from the Alias
directive is lost. This is
unfortunate, but we feel that using the filesystem to pass along this
sort of information is not a recommended method, and a script making
use of it "deserves" not to work. Apache 1.2b3 and later, however, do
-provide a workaround.
+provide a workaround.
-
It may be necessary for a script that was designed for earlier +
It may be necessary for a script that was designed for earlier versions of Apache or other servers to need the information that the old PATH_INFO variable provided. For this purpose, Apache 1.2 (1.2b3 and later) sets an additional variable, FILEPATH_INFO. This environment variable contains the value that PATH_INFO would have had -with Apache 1.1.1.
+with Apache 1.1.1. -A script that wishes to work with both Apache 1.2 and earlier +
A script that wishes to work with both Apache 1.2 and earlier versions can simply test for the existence of FILEPATH_INFO, and use it if available. Otherwise, it can use PATH_INFO. For example, in Perl, one might use: -
+-$path_info = $ENV{'FILEPATH_INFO'} || $ENV{'PATH_INFO'}; -+
By doing this, a script can work with all servers supporting the -CGI/1.1 specification, including all versions of Apache.
+By doing this, a script can work with all servers supporting the +CGI/1.1 specification, including all versions of Apache.
diff --git a/docs/manual/content-negotiation.html b/docs/manual/content-negotiation.html index c6b096a688..2a0abb5ccd 100644 --- a/docs/manual/content-negotiation.html +++ b/docs/manual/content-negotiation.html @@ -13,25 +13,25 @@ ALINK="#FF0000" > -+
Apache's support for content negotiation has been updated to meet the HTTP/1.1 specification. It can choose the best representation of a resource based on the browser-supplied preferences for media type, languages, character set and encoding. It is also implements a couple of features to give more intelligent handling of requests from -browsers which send incomplete negotiation information.
+browsers which send incomplete negotiation information.
Content negotiation is provided by the -mod_negotiation module, +mod_negotiation module, which is compiled in by default. -
+
A resource may be available in several different representations. For example, it might be available in different languages or different media types, or a combination. One way of selecting the most @@ -44,14 +44,14 @@ information in French, if possible, else English will do. Browsers indicate their preferences by headers in the request. To request only French representations, the browser would send -
+-Accept-Language: fr -+
+
Note that this preference will only be applied when there is a choice of representations and they vary by language. -
+
As an example of a more complex request, this browser has been configured to accept French and English, but prefer French, and to @@ -59,54 +59,54 @@ accept various media types, preferring HTML over plain text or other text types, and preferring GIF or JPEG over other media types, but also allowing any other media type as a last resort: -
+Apache 1.2 supports 'server driven' content negotiation, as defined in the HTTP/1.1 specification. It fully supports the Accept, Accept-Language, Accept-Charset and Accept-Encoding request headers. -Accept-Language: fr; q=1.0, en; q=0.5 Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1 -+
+
-The terms used in content negotiation are: a resource is an +The terms used in content negotiation are: a resource is an item which can be requested of a server, which might be selected as the result of a content negotiation algorithm. If a resource is -available in several formats, these are called representations -or variants. The ways in which the variants for a particular -resource vary are called the dimensions of negotiation. +available in several formats, these are called representations +or variants. The ways in which the variants for a particular +resource vary are called the dimensions of negotiation.
+
In order to negotiate a resource, the server needs to be given information about each of the variants. This is done in one of two ways: -
*.var
file) which
+*.var
file) which
names the files containing the variants explicitly
- +
A type map is a document which is associated with the handler
-named type-map
(or, for backwards-compatibility with
+named type-map
(or, for backwards-compatibility with
older Apache configurations, the mime type
-application/x-type-map
). Note that to use this feature,
-you've got to have a SetHandler
some place which defines a
-file suffix as type-map
; this is best done with a
-
++inapplication/x-type-map
). Note that to use this feature, +you've got to have aSetHandler
some place which defines a +file suffix astype-map
; this is best done with a +AddHandler type-map var --insrm.conf
. See comments in the sample config files for -details.+
srm.conf
. See comments in the sample config files for
+details. Type map files have an entry for each available variant; these entries consist of contiguous RFC822-format header lines. Entries for @@ -115,7 +115,7 @@ illegal within an entry. It is conventional to begin a map file with an entry for the combined entity as a whole (although this is not required, and if present will be ignored). An example map file is: -
+If the variants have different source qualities, that may be indicated by the "qs" parameter to the media type, as in this picture (available as jpeg, gif, or ASCII-art): -URI: foo @@ -126,12 +126,12 @@ map file is: URI: foo.fr.de.html Content-type: text/html; charset=iso-8859-2 Content-language: fr, de -+
++URI: foo URI: foo.jpeg @@ -143,83 +143,83 @@ as jpeg, gif, or ASCII-art): URI: foo.txt Content-type: text/plain; qs=0.01 --+
qs values can vary between 0.000 and 1.000. Note that any variant with a qs value of 0.000 will never be chosen. Variants with no 'qs' -parameter value are given a qs factor of 1.0.
+parameter value are given a qs factor of 1.0.
The full list of headers recognized is: -
URI:
- URI:
+ Content-type:
- Content-type:
+ image/gif
, text/plain
, or
- text/html; level=3
.
- Content-language:
- en
for English,
- kr
for Korean, etc.).
- Content-encoding:
- image/gif
, text/plain
, or
+ text/html; level=3
.
+ Content-language:
+ en
for English,
+ kr
for Korean, etc.).
+ Content-encoding:
+ x-compress
, or x-gzip
, as appropriate.
- Content-length:
- x-compress
, or x-gzip
, as appropriate.
+ Content-length:
+ +
This is a per-directory option, meaning it can be set with an
-Options
directive within a <Directory>
,
-<Location>
or <Files>
-section in access.conf
, or (if AllowOverride
-is properly set) in .htaccess
files. Note that
-Options All
does not set MultiViews
; you
+Options
directive within a <Directory>
,
+<Location>
or <Files>
+section in access.conf
, or (if AllowOverride
+is properly set) in .htaccess
files. Note that
+Options All
does not set MultiViews
; you
have to ask for it by name. (Fixing this is a one-line change to
-http_core.h
).
+http_core.h
).
-
+
-The effect of MultiViews
is as follows: if the server
-receives a request for /some/dir/foo
, if
-/some/dir
has MultiViews
enabled, and
-/some/dir/foo
does not exist, then the server reads the
+The effect of MultiViews
is as follows: if the server
+receives a request for /some/dir/foo
, if
+/some/dir
has MultiViews
enabled, and
+/some/dir/foo
does not exist, then the server reads the
directory looking for files named foo.*, and effectively fakes up a
type map which names all those files, assigning them the same media
types and content-encodings it would have if the client had asked for
one of them by name. It then chooses the best match to the client's
requirements, and forwards them along.
-
+
This applies to searches for the file named by the
-DirectoryIndex
directive, if the server is trying to
+DirectoryIndex
directive, if the server is trying to
index a directory; if the configuration files specify
-
+then the server will arbitrate betweenDirectoryIndex index -then the server will arbitrate betweenindex.html
-andindex.html3
if both are present. If neither are -present, andindex.cgi
is there, the server will run it. +
index.html
+and index.html3
if both are present. If neither are
+present, and index.cgi
is there, the server will run it.
-+
If one of the files found when reading the directive is a CGI script, it's not obvious what should happen. The code gives that case @@ -238,7 +238,7 @@ any. To do this it calculates a quality value for each variant in each of the dimensions of variance. It is not necessary to know any of the details of how negotiation actually takes place in order to use Apache's content negotiation features. However the rest of this document -explains in detail the algorithm used for those interested.
+explains in detail the algorithm used for those interested.
In some circumstances, Apache can 'fiddle' the quality factor of a particular dimension to achieve a better result. The ways Apache can @@ -246,93 +246,93 @@ fiddle quality factors is explained in more detail below.
Dimension - | Notes - | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Media Type - | Browser indicates preferences on Accept: header. Each item
+
|
+
Apache uses an algorithm to select the 'best' variant (if any) to return to the browser. This algorithm is not configurable. It operates like this: -
LanguagePriority
directive (if present),
+LanguagePriority
directive (if present),
else the order of languages on the Accept-Language header.
-+
Apache sometimes changes the quality values from what would be expected by a strict interpretation of the algorithm above. This is to get a better result from the algorithm for browsers which do not send @@ -341,25 +341,25 @@ Accept header information which would otherwise result in the selection of the wrong variant in many cases. If a browser sends full and correct information these fiddles will not be applied. -
+
+
The Accept: request header indicates preferences for media types. It can also include 'wildcard' media types, such as "image/*" or "*/*" where the * matches any string. So a request including: -
+would indicate that any type starting "image/" is acceptable, as is any other type (so the first "image/*" is redundant). Some browsers routinely send wildcards in addition to explicit types they can handle. For example: -Accept: image/*, */* -+
+The intention of this is to indicate that the explicitly listed types are preferred, but if a different representation is @@ -368,30 +368,30 @@ above, the */* wildcard has exactly equal preference to all the other types, so they are not being preferred. The browser should really have sent a request with a lower quality (preference) value for *.*, such as: -Accept: text/html, text/plain, image/gif, image/jpeg, */* -+
+The explicit types have no quality factor, so they default to a preference of 1.0 (the highest). The wildcard */* is given a low preference of 0.01, so other types will only be returned if no variant matches an explicitly listed type. -Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01 -+
+
-If the Accept: header contains no q factors at all, Apache sets +If the Accept: header contains no q factors at all, Apache sets the q value of "*/*", if present, to 0.01 to emulate the desired behavior. It also sets the q value of wildcards of the format "type/*" to 0.02 (so these are preferred over matches against "*/*". If any media type on the Accept: header contains a q factor, -these special values are not applied, so requests from browsers +these special values are not applied, so requests from browsers which send the correct information to start with work as expected.
+
If some of the variants for a particular resource have a language attribute, and some do not, those variants with no language -are given a very low language quality factor of 0.001.
+are given a very low language quality factor of 0.001.
The reason for setting this language quality factor for variant with no language to a very low value is to allow @@ -400,13 +400,13 @@ other variants match the browser's language preferences. For example, consider the situation with three variants: -
+
The meaning of a variant with no language is that it is always acceptable to the browser. If the request Accept-Language header includes either en or fr (or both) one of foo.en.html @@ -415,94 +415,94 @@ either en or fr as acceptable, foo.html will be returned instead.
+
If you are using language negotiation you can choose between different naming conventions, because files can have more than one extension, and the order of the extensions is normally irrelevant -(see mod_mime documentation for details). -
-A typical file has a mime-type extension (e.g. html), -maybe an encoding extension (e.g. gz and of course a -language extension (e.g. en) when we have different +(see mod_mime documentation for details). +
+A typical file has a mime-type extension (e.g. html), +maybe an encoding extension (e.g. gz and of course a +language extension (e.g. en) when we have different language variants of this file. -
+
Examples: -
+
Here some more examples of filenames together with valid and invalid hyperlinks: -
+Filename | -Valid hyperlink | -Invalid hyperlink | -
---|---|---|
foo.html.en | -foo - foo.html |
- - | -
foo.en.html | -foo | -foo.html | -
foo.html.en.gz | -foo - foo.html |
- foo.gz - foo.html.gz |
-
foo.en.html.gz | -foo | -foo.html - foo.html.gz - foo.gz |
-
foo.gz.html.en | -foo - foo.gz - foo.gz.html |
- foo.html | -
foo.html.gz.en | -foo - foo.html - foo.html.gz |
- foo.gz | -
+
Looking at the table above you will notice that it is always possible to -use the name without any extensions in an hyperlink (e.g. foo). +use the name without any extensions in an hyperlink (e.g. foo). The advantage is that you can hide the actual type of a -document rsp. file and can change it later, e.g. from html -to shtml or cgi without changing any +document rsp. file and can change it later, e.g. from html +to shtml or cgi without changing any hyperlink references. -
+
If you want to continue to use a mime-type in your hyperlinks (e.g. -foo.html) the language extension (including an encoding extension +foo.html) the language extension (including an encoding extension if there is one) must be on the right hand side of the mime-type extension -(e.g. foo.html.en). +(e.g. foo.html.en).
+
When a cache stores a document, it associates it with the request URL. The next time that URL is requested, the cache can use the stored document, provided it is still within date. But if the resource is @@ -514,7 +514,7 @@ as non-cacheable by HTTP/1.0 clients. Apache also supports the HTTP/1.1 protocol features to allow caching of negotiated responses.
For requests which come from a HTTP/1.0 compliant client (either a -browser or a cache), the directive CacheNegotiatedDocs can be +browser or a cache), the directive CacheNegotiatedDocs can be used to allow caching of responses which were subject to negotiation. This directive can be given in the server config or virtual host, and takes no arguments. It has no effect on requests from HTTP/1.1 diff --git a/docs/manual/content-negotiation.html.en b/docs/manual/content-negotiation.html.en index c6b096a688..2a0abb5ccd 100644 --- a/docs/manual/content-negotiation.html.en +++ b/docs/manual/content-negotiation.html.en @@ -13,25 +13,25 @@ ALINK="#FF0000" > -
+
Apache's support for content negotiation has been updated to meet the HTTP/1.1 specification. It can choose the best representation of a resource based on the browser-supplied preferences for media type, languages, character set and encoding. It is also implements a couple of features to give more intelligent handling of requests from -browsers which send incomplete negotiation information.
+browsers which send incomplete negotiation information.
Content negotiation is provided by the -mod_negotiation module, +mod_negotiation module, which is compiled in by default. -
+
A resource may be available in several different representations. For example, it might be available in different languages or different media types, or a combination. One way of selecting the most @@ -44,14 +44,14 @@ information in French, if possible, else English will do. Browsers indicate their preferences by headers in the request. To request only French representations, the browser would send -
+-Accept-Language: fr -+
+
Note that this preference will only be applied when there is a choice of representations and they vary by language. -
+
As an example of a more complex request, this browser has been configured to accept French and English, but prefer French, and to @@ -59,54 +59,54 @@ accept various media types, preferring HTML over plain text or other text types, and preferring GIF or JPEG over other media types, but also allowing any other media type as a last resort: -
+Apache 1.2 supports 'server driven' content negotiation, as defined in the HTTP/1.1 specification. It fully supports the Accept, Accept-Language, Accept-Charset and Accept-Encoding request headers. -Accept-Language: fr; q=1.0, en; q=0.5 Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1 -+
+
-The terms used in content negotiation are: a resource is an +The terms used in content negotiation are: a resource is an item which can be requested of a server, which might be selected as the result of a content negotiation algorithm. If a resource is -available in several formats, these are called representations -or variants. The ways in which the variants for a particular -resource vary are called the dimensions of negotiation. +available in several formats, these are called representations +or variants. The ways in which the variants for a particular +resource vary are called the dimensions of negotiation.
+
In order to negotiate a resource, the server needs to be given information about each of the variants. This is done in one of two ways: -
*.var
file) which
+*.var
file) which
names the files containing the variants explicitly
- +
A type map is a document which is associated with the handler
-named type-map
(or, for backwards-compatibility with
+named type-map
(or, for backwards-compatibility with
older Apache configurations, the mime type
-application/x-type-map
). Note that to use this feature,
-you've got to have a SetHandler
some place which defines a
-file suffix as type-map
; this is best done with a
-
++inapplication/x-type-map
). Note that to use this feature, +you've got to have aSetHandler
some place which defines a +file suffix astype-map
; this is best done with a +AddHandler type-map var --insrm.conf
. See comments in the sample config files for -details.+
srm.conf
. See comments in the sample config files for
+details. Type map files have an entry for each available variant; these entries consist of contiguous RFC822-format header lines. Entries for @@ -115,7 +115,7 @@ illegal within an entry. It is conventional to begin a map file with an entry for the combined entity as a whole (although this is not required, and if present will be ignored). An example map file is: -
+If the variants have different source qualities, that may be indicated by the "qs" parameter to the media type, as in this picture (available as jpeg, gif, or ASCII-art): -URI: foo @@ -126,12 +126,12 @@ map file is: URI: foo.fr.de.html Content-type: text/html; charset=iso-8859-2 Content-language: fr, de -+
++URI: foo URI: foo.jpeg @@ -143,83 +143,83 @@ as jpeg, gif, or ASCII-art): URI: foo.txt Content-type: text/plain; qs=0.01 --+
qs values can vary between 0.000 and 1.000. Note that any variant with a qs value of 0.000 will never be chosen. Variants with no 'qs' -parameter value are given a qs factor of 1.0.
+parameter value are given a qs factor of 1.0.
The full list of headers recognized is: -
URI:
- URI:
+ Content-type:
- Content-type:
+ image/gif
, text/plain
, or
- text/html; level=3
.
- Content-language:
- en
for English,
- kr
for Korean, etc.).
- Content-encoding:
- image/gif
, text/plain
, or
+ text/html; level=3
.
+ Content-language:
+ en
for English,
+ kr
for Korean, etc.).
+ Content-encoding:
+ x-compress
, or x-gzip
, as appropriate.
- Content-length:
- x-compress
, or x-gzip
, as appropriate.
+ Content-length:
+ +
This is a per-directory option, meaning it can be set with an
-Options
directive within a <Directory>
,
-<Location>
or <Files>
-section in access.conf
, or (if AllowOverride
-is properly set) in .htaccess
files. Note that
-Options All
does not set MultiViews
; you
+Options
directive within a <Directory>
,
+<Location>
or <Files>
+section in access.conf
, or (if AllowOverride
+is properly set) in .htaccess
files. Note that
+Options All
does not set MultiViews
; you
have to ask for it by name. (Fixing this is a one-line change to
-http_core.h
).
+http_core.h
).
-
+
-The effect of MultiViews
is as follows: if the server
-receives a request for /some/dir/foo
, if
-/some/dir
has MultiViews
enabled, and
-/some/dir/foo
does not exist, then the server reads the
+The effect of MultiViews
is as follows: if the server
+receives a request for /some/dir/foo
, if
+/some/dir
has MultiViews
enabled, and
+/some/dir/foo
does not exist, then the server reads the
directory looking for files named foo.*, and effectively fakes up a
type map which names all those files, assigning them the same media
types and content-encodings it would have if the client had asked for
one of them by name. It then chooses the best match to the client's
requirements, and forwards them along.
-
+
This applies to searches for the file named by the
-DirectoryIndex
directive, if the server is trying to
+DirectoryIndex
directive, if the server is trying to
index a directory; if the configuration files specify
-
+then the server will arbitrate betweenDirectoryIndex index -then the server will arbitrate betweenindex.html
-andindex.html3
if both are present. If neither are -present, andindex.cgi
is there, the server will run it. +
index.html
+and index.html3
if both are present. If neither are
+present, and index.cgi
is there, the server will run it.
-+
If one of the files found when reading the directive is a CGI script, it's not obvious what should happen. The code gives that case @@ -238,7 +238,7 @@ any. To do this it calculates a quality value for each variant in each of the dimensions of variance. It is not necessary to know any of the details of how negotiation actually takes place in order to use Apache's content negotiation features. However the rest of this document -explains in detail the algorithm used for those interested.
+explains in detail the algorithm used for those interested.
In some circumstances, Apache can 'fiddle' the quality factor of a particular dimension to achieve a better result. The ways Apache can @@ -246,93 +246,93 @@ fiddle quality factors is explained in more detail below.
Dimension - | Notes - | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Media Type - | Browser indicates preferences on Accept: header. Each item
+
|
+
Apache uses an algorithm to select the 'best' variant (if any) to return to the browser. This algorithm is not configurable. It operates like this: -
LanguagePriority
directive (if present),
+LanguagePriority
directive (if present),
else the order of languages on the Accept-Language header.
-+
Apache sometimes changes the quality values from what would be expected by a strict interpretation of the algorithm above. This is to get a better result from the algorithm for browsers which do not send @@ -341,25 +341,25 @@ Accept header information which would otherwise result in the selection of the wrong variant in many cases. If a browser sends full and correct information these fiddles will not be applied. -
+
+
The Accept: request header indicates preferences for media types. It can also include 'wildcard' media types, such as "image/*" or "*/*" where the * matches any string. So a request including: -
+would indicate that any type starting "image/" is acceptable, as is any other type (so the first "image/*" is redundant). Some browsers routinely send wildcards in addition to explicit types they can handle. For example: -Accept: image/*, */* -+
+The intention of this is to indicate that the explicitly listed types are preferred, but if a different representation is @@ -368,30 +368,30 @@ above, the */* wildcard has exactly equal preference to all the other types, so they are not being preferred. The browser should really have sent a request with a lower quality (preference) value for *.*, such as: -Accept: text/html, text/plain, image/gif, image/jpeg, */* -+
+The explicit types have no quality factor, so they default to a preference of 1.0 (the highest). The wildcard */* is given a low preference of 0.01, so other types will only be returned if no variant matches an explicitly listed type. -Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01 -+
+
-If the Accept: header contains no q factors at all, Apache sets +If the Accept: header contains no q factors at all, Apache sets the q value of "*/*", if present, to 0.01 to emulate the desired behavior. It also sets the q value of wildcards of the format "type/*" to 0.02 (so these are preferred over matches against "*/*". If any media type on the Accept: header contains a q factor, -these special values are not applied, so requests from browsers +these special values are not applied, so requests from browsers which send the correct information to start with work as expected.
+
If some of the variants for a particular resource have a language attribute, and some do not, those variants with no language -are given a very low language quality factor of 0.001.
+are given a very low language quality factor of 0.001.
The reason for setting this language quality factor for variant with no language to a very low value is to allow @@ -400,13 +400,13 @@ other variants match the browser's language preferences. For example, consider the situation with three variants: -
+
The meaning of a variant with no language is that it is always acceptable to the browser. If the request Accept-Language header includes either en or fr (or both) one of foo.en.html @@ -415,94 +415,94 @@ either en or fr as acceptable, foo.html will be returned instead.
+
If you are using language negotiation you can choose between different naming conventions, because files can have more than one extension, and the order of the extensions is normally irrelevant -(see mod_mime documentation for details). -
-A typical file has a mime-type extension (e.g. html), -maybe an encoding extension (e.g. gz and of course a -language extension (e.g. en) when we have different +(see mod_mime documentation for details). +
+A typical file has a mime-type extension (e.g. html), +maybe an encoding extension (e.g. gz and of course a +language extension (e.g. en) when we have different language variants of this file. -
+
Examples: -
+
Here some more examples of filenames together with valid and invalid hyperlinks: -
+Filename | -Valid hyperlink | -Invalid hyperlink | -
---|---|---|
foo.html.en | -foo - foo.html |
- - | -
foo.en.html | -foo | -foo.html | -
foo.html.en.gz | -foo - foo.html |
- foo.gz - foo.html.gz |
-
foo.en.html.gz | -foo | -foo.html - foo.html.gz - foo.gz |
-
foo.gz.html.en | -foo - foo.gz - foo.gz.html |
- foo.html | -
foo.html.gz.en | -foo - foo.html - foo.html.gz |
- foo.gz | -
+
Looking at the table above you will notice that it is always possible to -use the name without any extensions in an hyperlink (e.g. foo). +use the name without any extensions in an hyperlink (e.g. foo). The advantage is that you can hide the actual type of a -document rsp. file and can change it later, e.g. from html -to shtml or cgi without changing any +document rsp. file and can change it later, e.g. from html +to shtml or cgi without changing any hyperlink references. -
+
If you want to continue to use a mime-type in your hyperlinks (e.g. -foo.html) the language extension (including an encoding extension +foo.html) the language extension (including an encoding extension if there is one) must be on the right hand side of the mime-type extension -(e.g. foo.html.en). +(e.g. foo.html.en).
+
When a cache stores a document, it associates it with the request URL. The next time that URL is requested, the cache can use the stored document, provided it is still within date. But if the resource is @@ -514,7 +514,7 @@ as non-cacheable by HTTP/1.0 clients. Apache also supports the HTTP/1.1 protocol features to allow caching of negotiated responses.
For requests which come from a HTTP/1.0 compliant client (either a -browser or a cache), the directive CacheNegotiatedDocs can be +browser or a cache), the directive CacheNegotiatedDocs can be used to allow caching of responses which were subject to negotiation. This directive can be given in the server config or virtual host, and takes no arguments. It has no effect on requests from HTTP/1.1 diff --git a/docs/manual/custom-error.html b/docs/manual/custom-error.html index cdd4ac9b54..802bd5cbe3 100644 --- a/docs/manual/custom-error.html +++ b/docs/manual/custom-error.html @@ -55,28 +55,28 @@
To achieve this, Apache will define new CGI-like environment variables, e.g. -
-REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
-REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
-REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
-REDIRECT_QUERY_STRING=
-REDIRECT_REMOTE_ADDR=121.345.78.123
-REDIRECT_REMOTE_HOST=ooh.ahhh.com
-REDIRECT_SERVER_NAME=crash.bang.edu
-REDIRECT_SERVER_PORT=80
-REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
-REDIRECT_URL=/cgi-bin/buggy.pl
-
-
- note the REDIRECT_
prefix.
-
-
At least REDIRECT_URL
and REDIRECT_QUERY_STRING
will
+
+REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
+REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
+REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
+REDIRECT_QUERY_STRING=
+REDIRECT_REMOTE_ADDR=121.345.78.123
+REDIRECT_REMOTE_HOST=ooh.ahhh.com
+REDIRECT_SERVER_NAME=crash.bang.edu
+REDIRECT_SERVER_PORT=80
+REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
+REDIRECT_URL=/cgi-bin/buggy.pl
+
+
+ note the REDIRECT_
prefix.
+
+
At least REDIRECT_URL
and REDIRECT_QUERY_STRING
will
be passed to the new URL (assuming it's a cgi-script or a cgi-include). The
other variables will exist only if they existed prior to the error/problem.
- None of these will be set if your ErrorDocument is an
- external redirect (i.e. anything starting with a protocol name
- like http:
, even if it refers to the same host as the
- server).
+ None of these will be set if your ErrorDocument is an
+ external redirect (i.e. anything starting with a protocol name
+ like http:
, even if it refers to the same host as the
+ server).
Here are some examples... -
-ErrorDocument 500 /cgi-bin/crash-recover
-ErrorDocument 500 "Sorry, our script crashed. Oh dear
-ErrorDocument 500 http://xxx/
-ErrorDocument 404 /Lame_excuses/not_found.html
+
+ErrorDocument 500 /cgi-bin/crash-recover
+ErrorDocument 500 "Sorry, our script crashed. Oh dear
+ErrorDocument 500 http://xxx/
+ErrorDocument 404 /Lame_excuses/not_found.html
ErrorDocument 401 /Subscription/how_to_subscribe.html
-
+
The syntax is, -
ErrorDocument
<3-digit-code> action
where the action can be,
+ environment variables are available to a script/server-include.
+
REDIRECT_
. REDIRECT_
environment
+prefix REDIRECT_
. REDIRECT_
environment
variables are created from the CGI environment variables which existed
-prior to the redirect, they are renamed with a REDIRECT_
-prefix, i.e. HTTP_USER_AGENT
becomes
-REDIRECT_HTTP_USER_AGENT
. In addition to these new
-variables, Apache will define REDIRECT_URL
and
-REDIRECT_STATUS
to help the script trace its origin.
+prior to the redirect, they are renamed with a REDIRECT_
+prefix, i.e. HTTP_USER_AGENT
becomes
+REDIRECT_HTTP_USER_AGENT
. In addition to these new
+variables, Apache will define REDIRECT_URL
and
+REDIRECT_STATUS
to help the script trace its origin.
Both the original URL and the URL being redirected to can be logged in
the access log.
diff --git a/docs/manual/custom-error.html.en b/docs/manual/custom-error.html.en
index cdd4ac9b54..802bd5cbe3 100644
--- a/docs/manual/custom-error.html.en
+++ b/docs/manual/custom-error.html.en
@@ -55,28 +55,28 @@
To achieve this, Apache will define new CGI-like environment variables, e.g. -
-REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
-REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
-REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
-REDIRECT_QUERY_STRING=
-REDIRECT_REMOTE_ADDR=121.345.78.123
-REDIRECT_REMOTE_HOST=ooh.ahhh.com
-REDIRECT_SERVER_NAME=crash.bang.edu
-REDIRECT_SERVER_PORT=80
-REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
-REDIRECT_URL=/cgi-bin/buggy.pl
-
-
- note the REDIRECT_
prefix.
-
-
At least REDIRECT_URL
and REDIRECT_QUERY_STRING
will
+
+REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg
+REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712)
+REDIRECT_PATH=.:/bin:/usr/local/bin:/etc
+REDIRECT_QUERY_STRING=
+REDIRECT_REMOTE_ADDR=121.345.78.123
+REDIRECT_REMOTE_HOST=ooh.ahhh.com
+REDIRECT_SERVER_NAME=crash.bang.edu
+REDIRECT_SERVER_PORT=80
+REDIRECT_SERVER_SOFTWARE=Apache/0.8.15
+REDIRECT_URL=/cgi-bin/buggy.pl
+
+
+ note the REDIRECT_
prefix.
+
+
At least REDIRECT_URL
and REDIRECT_QUERY_STRING
will
be passed to the new URL (assuming it's a cgi-script or a cgi-include). The
other variables will exist only if they existed prior to the error/problem.
- None of these will be set if your ErrorDocument is an
- external redirect (i.e. anything starting with a protocol name
- like http:
, even if it refers to the same host as the
- server).
+ None of these will be set if your ErrorDocument is an
+ external redirect (i.e. anything starting with a protocol name
+ like http:
, even if it refers to the same host as the
+ server).
Here are some examples... -
-ErrorDocument 500 /cgi-bin/crash-recover
-ErrorDocument 500 "Sorry, our script crashed. Oh dear
-ErrorDocument 500 http://xxx/
-ErrorDocument 404 /Lame_excuses/not_found.html
+
+ErrorDocument 500 /cgi-bin/crash-recover
+ErrorDocument 500 "Sorry, our script crashed. Oh dear
+ErrorDocument 500 http://xxx/
+ErrorDocument 404 /Lame_excuses/not_found.html
ErrorDocument 401 /Subscription/how_to_subscribe.html
-
+
The syntax is, -
ErrorDocument
<3-digit-code> action
where the action can be,
+ environment variables are available to a script/server-include.
+
REDIRECT_
. REDIRECT_
environment
+prefix REDIRECT_
. REDIRECT_
environment
variables are created from the CGI environment variables which existed
-prior to the redirect, they are renamed with a REDIRECT_
-prefix, i.e. HTTP_USER_AGENT
becomes
-REDIRECT_HTTP_USER_AGENT
. In addition to these new
-variables, Apache will define REDIRECT_URL
and
-REDIRECT_STATUS
to help the script trace its origin.
+prior to the redirect, they are renamed with a REDIRECT_
+prefix, i.e. HTTP_USER_AGENT
becomes
+REDIRECT_HTTP_USER_AGENT
. In addition to these new
+variables, Apache will define REDIRECT_URL
and
+REDIRECT_STATUS
to help the script trace its origin.
Both the original URL and the URL being redirected to can be logged in
the access log.
diff --git a/docs/manual/developer/API.html b/docs/manual/developer/API.html
index dba84c18d5..fdcd8737a3 100644
--- a/docs/manual/developer/API.html
+++ b/docs/manual/developer/API.html
@@ -1,7 +1,7 @@
-
-+
A few notes on general pedagogical style here. In the interest of conciseness, all structure declarations here are incomplete --- the @@ -28,77 +28,77 @@ real ones have more slots that I'm not telling you about. For the most part, these are reserved to one component of the server core or another, and should be altered by modules with caution. However, in some cases, they really are things I just haven't gotten around to -yet. Welcome to the bleeding edge.
+yet. Welcome to the bleeding edge.
Finally, here's an outline, to give you some bare idea of what's coming up, and in what order: -
SetEnv
, which don't really fit well elsewhere.
- SetEnv
, which don't really fit well elsewhere.
+ OK
.
- DECLINED
. In this case, the
+OK
.
+ DECLINED
. In this case, the
server behaves in all respects as if the handler simply hadn't
been there.
- */*
(i.e., a
+any request, by giving it the key */*
(i.e., a
wildcard MIME type specification). However, wildcard handlers are
only invoked if the server has already tried and failed to find a more
specific response handler for the MIME type of the requested object
-(either none existed, or they all declined).+(either none existed, or they all declined).
The handlers themselves are functions of one argument (a
-request_rec
structure. vide infra), which returns an
-integer, as above.
+request_rec
structure. vide infra), which returns an
+integer, as above.
-
ScriptAlias
config file
+handles both CGI scripts and the ScriptAlias
config file
command. It's actually a great deal more complicated than most
modules, but if we're going to have only one example, it might as well
-be the one with its fingers in every place.+be the one with its fingers in every place.
Let's begin with handlers. In order to handle the CGI scripts, the
module declares a response handler for them. Because of
-ScriptAlias
, it also has handlers for the name
-translation phase (to recognize ScriptAlias
ed URIs), the
-type-checking phase (any ScriptAlias
ed request is typed
-as a CGI script).
+ScriptAlias
, it also has handlers for the name
+translation phase (to recognize ScriptAlias
ed URIs), the
+type-checking phase (any ScriptAlias
ed request is typed
+as a CGI script).
The module needs to maintain some per (virtual)
-server information, namely, the ScriptAlias
es in effect;
+server information, namely, the ScriptAlias
es in effect;
the module structure therefore contains pointers to a functions which
builds these structures, and to another which combines two of them (in
case the main server and a virtual server both have
-ScriptAlias
es declared).
+ScriptAlias
es declared).
Finally, this module contains code to handle the
-ScriptAlias
command itself. This particular module only
+ScriptAlias
command itself. This particular module only
declares one command, but there could be more, so modules have
-command tables which declare their commands, and describe
-where they are permitted, and how they are to be invoked.
+command tables which declare their commands, and describe +where they are permitted, and how they are to be invoked.
A final note on the declared types of the arguments of some of these
-commands: a pool
is a pointer to a resource pool
+commands: a pool
is a pointer to a resource pool
structure; these are used by the server to keep track of the memory
which has been allocated, files opened, etc., either to service a
particular request, or to handle the process of configuring itself.
That way, when the request is over (or, for the configuration pool,
when the server is restarting), the memory can be freed, and the files
-closed, en masse, without anyone having to write explicit code to
+closed, en masse, without anyone having to write explicit code to
track them all down and dispose of them. Also, a
-cmd_parms
structure contains various information about
+cmd_parms
structure contains various information about
the config file being read, and other status information, which is
sometimes of use to the function which processes a config-file command
-(such as ScriptAlias
).
+(such as ScriptAlias
).
With no further ado, the module itself:
-
+-/* Declarations of handlers. */ int translate_scriptalias (request_rec *); @@ -213,34 +213,34 @@ module cgi_module = { NULL, /* logger */ NULL /* header parser */ }; -+
request_rec
structure.
+The sole argument to handlers is a request_rec
structure.
This structure describes a particular request which has been made to
the server, on behalf of a client. In most cases, each connection to
-the client generates only one request_rec
structure.
+the client generates only one request_rec
structure.
-
request_rec
request_rec
request_rec
contains pointers to a resource pool
+The request_rec
contains pointers to a resource pool
which will be cleared when the server is finished handling the
request; to structures containing per-server and per-connection
-information, and most importantly, information on the request itself.+information, and most importantly, information on the request itself.
The most important such information is a small set of character strings describing attributes of the object being requested, including its URI, filename, content-type and content-encoding (these being filled in by the translation and type-check handlers which handle the -request, respectively).
+request, respectively).
Other commonly used data items are tables giving the MIME headers on
the client's original request, MIME headers to be sent back with the
response (which modules can add to at will), and environment variables
for any subprocesses which are spawned off in the course of servicing
the request. These tables are manipulated using the
-table_get
and table_set
routines.
+table_get
and table_set
routines.
Note that the Content-type header value cannot be set by module content-handlers using the table_*() @@ -255,17 +255,17 @@ Finally, there are pointers to two data structures which, in turn, point to per-module configuration structures. Specifically, these hold pointers to the data structures which the module has built to describe the way it has been configured to operate in a given -directory (via.htaccess
files or -<Directory>
sections), for private data it has +directory (via.htaccess
files or +<Directory>
sections), for private data it has built in the course of servicing the request (so modules' handlers for one phase can pass `notes' to their handlers for other phases). There -is another such configuration vector in theserver_rec
-data structure pointed to by therequest_rec
, which -contains per (virtual) server configuration data.+is another such configuration vector in the
server_rec
+data structure pointed to by therequest_rec
, which +contains per (virtual) server configuration data.-Here is an abridged declaration, giving the fields most commonly used:
+Here is an abridged declaration, giving the fields most commonly used:
-
+-struct request_rec { pool *pool; @@ -327,101 +327,101 @@ struct request_rec { }; -+Where request_rec structures come from
+Where request_rec structures come from
-Mostrequest_rec
structures are built by reading an HTTP +Mostrequest_rec
structures are built by reading an HTTP request from a client, and filling in the fields. However, there are a few exceptions: --
-- If the request is to an imagemap, a type map (i.e., a -
*.var
file), or a CGI script which returned a ++
+ function- If the request is to an imagemap, a type map (i.e., a +
*.var
file), or a CGI script which returned a local `Location:', then the resource which the user requested is going to be ultimately located by some URI other than what the client originally supplied. In this case, the server does - an internal redirect, constructing a new -request_rec
for the new URI, and processing it + an internal redirect, constructing a new +request_rec
for the new URI, and processing it almost exactly as if the client had requested the new URI - directly.+ directly.
-
- If some handler signaled an error, and an -
ErrorDocument
is in scope, the same internal - redirect machinery comes into play.+
- If some handler signaled an error, and an +
ErrorDocument
is in scope, the same internal + redirect machinery comes into play.-
- Finally, a handler occasionally needs to investigate `what +
- Finally, a handler occasionally needs to investigate `what would happen if' some other request were run. For instance, the directory indexing module needs to know what MIME type would be assigned to a request for each directory entry, in - order to figure out what icon to use.
+ order to figure out what icon to use.
- Such handlers can construct a sub-request, using the - functions
sub_req_lookup_file
and -sub_req_lookup_uri
; this constructs a new -request_rec
structure and processes it as you + Such handlers can construct a sub-request, using the + functionssub_req_lookup_file
and +sub_req_lookup_uri
; this constructs a new +request_rec
structure and processes it as you would expect, up to but not including the point of actually sending a response. (These functions skip over the access checks if the sub-request is for a file in the same directory - as the original request).+ as the original request).
(Server-side includes work by building sub-requests and then actually invoking the response handler for them, via the - function
run_sub_request
). -run_sub_request
). +Handling requests, declining, and returning error codes
+Handling requests, declining, and returning error codes
As discussed above, each handler, when invoked to handle a particular -request_rec
, has to return anint
to +request_rec
, has to return anint
to indicate what happened. That can either be --
-Note that if the error code returned is- OK --- the request was handled successfully. This may or may +
+
+- OK --- the request was handled successfully. This may or may not terminate the phase. -
- DECLINED --- no erroneous condition exists, but the module +
- DECLINED --- no erroneous condition exists, but the module declines to handle the phase; the server tries to find another. -
- an HTTP error code, which aborts handling of the request. -
- an HTTP error code, which aborts handling of the request. +
REDIRECT
, then -the module should put aLocation
in the request's -headers_out
, to indicate where the client should be -redirected to.+Note that if the error code returned is
REDIRECT
, then +the module should put aLocation
in the request's +headers_out
, to indicate where the client should be +redirected to.-
Special considerations for response handlers
+Special considerations for response handlers
Handlers for most phases do their work by simply setting a few fields -in therequest_rec
structure (or, in the case of access +in therequest_rec
structure (or, in the case of access checkers, simply by returning the correct error code). However, -response handlers have to actually send a request back to the client.+response handlers have to actually send a request back to the client.
They should begin by sending an HTTP response header, using the -function
send_http_header
. (You don't have to do +functionsend_http_header
. (You don't have to do anything special to skip sending the header for HTTP/0.9 requests; the function figures out on its own that it shouldn't do anything). If -the request is markedheader_only
, that's all they should +the request is markedheader_only
, that's all they should do; they should return after that, without attempting any further -output.+output.
Otherwise, they should produce a request body which responds to the -client as appropriate. The primitives for this are
rputc
-andrprintf
, for internally generated output, and -send_fd
, to copy the contents of someFILE *
-straight to the client.+client as appropriate. The primitives for this are
rputc
+andrprintf
, for internally generated output, and +send_fd
, to copy the contents of someFILE *
+straight to the client.At this point, you should more or less understand the following piece -of code, which is the handler which handles
GET
requests +of code, which is the handler which handlesGET
requests which have no more specific handler; it also shows how conditional -GET
s can be handled, if it's desirable to do so in a -particular response handler ---set_last_modified
checks -against theIf-modified-since
value supplied by the +GET
s can be handled, if it's desirable to do so in a +particular response handler ---set_last_modified
checks +against theIf-modified-since
value supplied by the client, if any, and returns an appropriate code (which will, if nonzero, be USE_LOCAL_COPY). No similar considerations apply for -set_content_length
, but it returns an error code for -symmetry.+
set_content_length
, but it returns an error code for +symmetry.-
+Finally, if all of this is too much of a challenge, there are a few ways out of it. First off, as shown above, a response handler which has not yet produced any output can simply return an error code, in which case the server will automatically produce an error response. Secondly, it can punt to some other handler by invoking -int default_handler (request_rec *r) { int errstatus; @@ -449,96 +449,96 @@ int default_handler (request_rec *r) pfclose (r->pool, f); return OK; } -+internal_redirect
, which is how the internal redirection +internal_redirect
, which is how the internal redirection machinery discussed above is invoked. A response handler which has -internally redirected should always returnOK
.+internally redirected should always return
OK
.-(Invoking
internal_redirect
from handlers which are -not response handlers will lead to serious confusion). +(Invokinginternal_redirect
from handlers which are +not response handlers will lead to serious confusion). -Special considerations for authentication handlers
+Special considerations for authentication handlers
Stuff that should be discussed here in detail: --
-- Authentication-phase handlers not invoked unless auth is +
+
+- Authentication-phase handlers not invoked unless auth is configured for the directory. -
- Common auth configuration stored in the core per-dir - configuration; it has accessors
auth_type
, -auth_name
, andrequires
. -- Common routines, to handle the protocol end of things, at least - for HTTP basic authentication (
get_basic_auth_pw
, - which sets theconnection->user
structure field - automatically, andnote_basic_auth_failure
, which - arranges for the properWWW-Authenticate:
header +- Common auth configuration stored in the core per-dir + configuration; it has accessors
auth_type
, +auth_name
, andrequires
. +- Common routines, to handle the protocol end of things, at least + for HTTP basic authentication (
get_basic_auth_pw
, + which sets theconnection->user
structure field + automatically, andnote_basic_auth_failure
, which + arranges for the properWWW-Authenticate:
header to be sent back). -Special considerations for logging handlers
+Special considerations for logging handlers
When a request has internally redirected, there is the question of what to log. Apache handles this by bundling the entire chain of -redirects into a list ofrequest_rec
structures which are -threaded through ther->prev
andr->next
-pointers. Therequest_rec
which is passed to the logging +redirects into a list ofrequest_rec
structures which are +threaded through ther->prev
andr->next
+pointers. Therequest_rec
which is passed to the logging handlers in such cases is the one which was originally built for the initial request from the client; note that the bytes_sent field will only be correct in the last request in the chain (the one for which a response was actually sent). -Resource allocation and resource pools
+Resource allocation and resource pools
One of the problems of writing and designing a server-pool server is that of preventing leakage, that is, allocating resources (memory, open files, etc.), without subsequently releasing them. The resource pool machinery is designed to make it easy to prevent this from happening, by allowing resource to be allocated in such a way that -they are automatically released when the server is done with -them.+they are automatically released when the server is done with +them.
The way this works is as follows: the memory which is allocated, file opened, etc., to deal with a particular request are tied to a -resource pool which is allocated for the request. The pool -is a data structure which itself tracks the resources in question.
+resource pool which is allocated for the request. The pool +is a data structure which itself tracks the resources in question.
-When the request has been processed, the pool is cleared. At +When the request has been processed, the pool is cleared. At that point, all the memory associated with it is released for reuse, all files associated with it are closed, and any other clean-up functions which are associated with the pool are run. When this is over, we can be confident that all the resource tied to the pool have -been released, and that none of them have leaked.
+been released, and that none of them have leaked.
Server restarts, and allocation of memory and resources for per-server configuration, are handled in a similar way. There is a -configuration pool, which keeps track of resources which were +configuration pool, which keeps track of resources which were allocated while reading the server configuration files, and handling the commands therein (for instance, the memory that was allocated for per-server module configuration, log files and other files that were opened, and so forth). When the server restarts, and has to reread the configuration files, the configuration pool is cleared, and so the memory and file descriptors which were taken up by reading them the -last time are made available for reuse.
+last time are made available for reuse.
It should be noted that use of the pool machinery isn't generally obligatory, except for situations like logging handlers, where you really need to register cleanups to make sure that the log file gets closed when the server restarts (this is most easily done by using the -function
pfopen
, which also +functionpfopen
, which also arranges for the underlying file descriptor to be closed before any -child processes, such as for CGI scripts, areexec
ed), or +child processes, such as for CGI scripts, areexec
ed), or in case you are using the timeout machinery (which isn't yet even documented here). However, there are two benefits to using it: resources allocated to a pool never leak (even if you allocate a scratch string, and just forget about it); also, for memory -allocation,palloc
is generally faster than -malloc
.+allocation,
palloc
is generally faster than +malloc
.We begin here by describing how memory is allocated to pools, and then discuss how other resources are tracked by the resource pool @@ -547,15 +547,15 @@ machinery.
Allocation of memory in pools
Memory is allocated to pools by calling the function -palloc
, which takes two arguments, one being a pointer to +palloc
, which takes two arguments, one being a pointer to a resource pool structure, and the other being the amount of memory to -allocate (inchar
s). Within handlers for handling +allocate (inchar
s). Within handlers for handling requests, the most common way of getting a resource pool structure is -by looking at thepool
slot of the relevant -request_rec
; hence the repeated appearance of the +by looking at thepool
slot of the relevant +request_rec
; hence the repeated appearance of the following idiom in module code: -+-Note that there is noint my_handler(request_rec *r) { struct my_structure *foo; @@ -563,20 +563,20 @@ int my_handler(request_rec *r) foo = (foo *)palloc (r->pool, sizeof(my_structure)); } -+pfree
--- -palloc
ed memory is freed only when the associated -resource pool is cleared. This means thatpalloc
does not -have to do as much accounting asmalloc()
; all it does in +Note that there is nopfree
--- +palloc
ed memory is freed only when the associated +resource pool is cleared. This means thatpalloc
does not +have to do as much accounting asmalloc()
; all it does in the typical case is to round up the size, bump a pointer, and do a -range check.+range check.
-(It also raises the possibility that heavy use of
palloc
+(It also raises the possibility that heavy use ofpalloc
could cause a server process to grow excessively large. There are two ways to deal with this, which are dealt with below; briefly, you -can usemalloc
, and try to be sure that all of the memory -gets explicitlyfree
d, or you can allocate a sub-pool of +can usemalloc
, and try to be sure that all of the memory +gets explicitlyfree
d, or you can allocate a sub-pool of the main pool, allocate your memory in the sub-pool, and clear it out periodically. The latter technique is discussed in the section on sub-pools below, and is used in the directory-indexing code, in order @@ -586,107 +586,107 @@ thousands of files).Allocating initialized memory
There are functions which allocate initialized memory, and are -frequently useful. The functionpcalloc
has the same -interface aspalloc
, but clears out the memory it -allocates before it returns it. The functionpstrdup
-takes a resource pool and achar *
as arguments, and +frequently useful. The functionpcalloc
has the same +interface aspalloc
, but clears out the memory it +allocates before it returns it. The functionpstrdup
+takes a resource pool and achar *
as arguments, and allocates memory for a copy of the string the pointer points to, -returning a pointer to the copy. Finallypstrcat
is a +returning a pointer to the copy. Finallypstrcat
is a varargs-style function, which takes a pointer to a resource pool, and -at least twochar *
arguments, the last of which must be -NULL
. It allocates enough memory to fit copies of each +at least twochar *
arguments, the last of which must be +NULL
. It allocates enough memory to fit copies of each of the strings, as a unit; for instance: -+returns a pointer to 8 bytes worth of memory, initialized to -pstrcat (r->pool, "foo", "/", "bar", NULL); -+"foo/bar"
. +"foo/bar"
. -Tracking open files, etc.
+Tracking open files, etc.
As indicated above, resource pools are also used to track other sorts of resources besides memory. The most common are open files. The -routine which is typically used for this ispfopen
, which +routine which is typically used for this ispfopen
, which takes a resource pool and two strings as arguments; the strings are -the same as the typical arguments tofopen
, e.g., +the same as the typical arguments tofopen
, e.g., -+-There is also a... FILE *f = pfopen (r->pool, r->filename, "r"); if (f == NULL) { ... } else { ... } -+popenf
routine, which parallels the -lower-levelopen
system call. Both of these routines +There is also apopenf
routine, which parallels the +lower-levelopen
system call. Both of these routines arrange for the file to be closed when the resource pool in question -is cleared.+is cleared.
-Unlike the case for memory, there are functions to close -files allocated with
pfopen
, andpopenf
, -namelypfclose
andpclosef
. (This is +Unlike the case for memory, there are functions to close +files allocated withpfopen
, andpopenf
, +namelypfclose
andpclosef
. (This is because, on many systems, the number of files which a single process can have open is quite limited). It is important to use these -functions to close files allocated withpfopen
and -popenf
, since to do otherwise could cause fatal errors on +functions to close files allocated withpfopen
and +popenf
, since to do otherwise could cause fatal errors on systems such as Linux, which react badly if the same -FILE*
is closed more than once.+
FILE*
is closed more than once.-(Using the
close
functions is not mandatory, since the +(Using theclose
functions is not mandatory, since the file will eventually be closed regardless, but you should consider it in cases where your module is opening, or could open, a lot of files).Other sorts of resources --- cleanup functions
More text goes here. Describe the the cleanup primitives in terms of -which the file stuff is implemented; also,spawn_process
. +which the file stuff is implemented; also,spawn_process
.Fine control --- creating and dealing with sub-pools, with a note on sub-requests
-On rare occasions, too-free use ofpalloc()
and the +On rare occasions, too-free use ofpalloc()
and the associated primitives may result in undesirably profligate resource allocation. You can deal with such a case by creating a -sub-pool, allocating within the sub-pool rather than the main +sub-pool, allocating within the sub-pool rather than the main pool, and clearing or destroying the sub-pool, which releases the -resources which were associated with it. (This really is a +resources which were associated with it. (This really is a rare situation; the only case in which it comes up in the standard module set is in case of listing directories, and then only with -very large directories. Unnecessary use of the primitives +very large directories. Unnecessary use of the primitives discussed here can hair up your code quite a bit, with very little -gain).+gain).
-The primitive for creating a sub-pool is
make_sub_pool
, +The primitive for creating a sub-pool ismake_sub_pool
, which takes another pool (the parent pool) as an argument. When the main pool is cleared, the sub-pool will be destroyed. The sub-pool may also be cleared or destroyed at any time, by calling the functions -clear_pool
anddestroy_pool
, respectively. -(The difference is thatclear_pool
frees resources -associated with the pool, whiledestroy_pool
also +clear_pool
anddestroy_pool
, respectively. +(The difference is thatclear_pool
frees resources +associated with the pool, whiledestroy_pool
also deallocates the pool itself. In the former case, you can allocate new resources within the pool, and clear it again, and so forth; in the -latter case, it is simply gone).+latter case, it is simply gone).
One final note --- sub-requests have their own resource pools, which are sub-pools of the resource pool for the main request. The polite way to reclaim the resources associated with a sub request which you -have allocated (using the
sub_req_lookup_...
functions) -isdestroy_sub_request
, which frees the resource pool. +have allocated (using thesub_req_lookup_...
functions) +isdestroy_sub_request
, which frees the resource pool. Before calling this function, be sure to copy anything that you care about which might be allocated in the sub-request's resource pool into someplace a little less volatile (for instance, the filename in its -request_rec
structure).+
request_rec
structure).(Again, under most circumstances, you shouldn't feel obliged to call this function; only 2K of memory or so are allocated for a typical sub request, and it will be freed anyway when the main request pool is cleared. It is only when you are allocating many, many sub-requests for a single main request that you should seriously consider the -
destroy...
functions). +destroy...
functions). -Configuration, commands and the like
+Configuration, commands and the like
One of the design goals for this server was to maintain external compatibility with the NCSA 1.3 server --- that is, to read the same @@ -696,7 +696,7 @@ hand, another design goal was to move as much of the server's functionality into modules which have as little as possible to do with the monolithic server core. The only way to reconcile these goals is to move the handling of most commands from the central server into the -modules.+modules.
However, just giving the modules command tables is not enough to divorce them completely from the server core. The server has to @@ -705,77 +705,77 @@ maintaining data which is private to the modules, and which can be either per-server, or per-directory. Most things are per-directory, including in particular access control and authorization information, but also information on how to determine file types from suffixes, -which can be modified by
AddType
and -DefaultType
directives, and so forth. In general, the -governing philosophy is that anything which can be made +which can be modified byAddType
and +DefaultType
directives, and so forth. In general, the +governing philosophy is that anything which can be made configurable by directory should be; per-server information is generally used in the standard set of modules for information like -Alias
es andRedirect
s which come into play +Alias
es andRedirect
s which come into play before the request is tied to a particular place in the underlying -file system.+file system.
Another requirement for emulating the NCSA server is being able to handle the per-directory configuration files, generally called -
.htaccess
files, though even in the NCSA server they can +.htaccess
files, though even in the NCSA server they can contain directives which have nothing at all to do with access control. Accordingly, after URI -> filename translation, but before performing any other phase, the server walks down the directory hierarchy of the underlying filesystem, following the translated -pathname, to read any.htaccess
files which might be +pathname, to read any.htaccess
files which might be present. The information which is read in then has to be -merged with the applicable information from the server's own -config files (either from the<Directory>
sections -inaccess.conf
, or from defaults in -srm.conf
, which actually behaves for most purposes almost -exactly like<Directory />
).+merged with the applicable information from the server's own +config files (either from the
<Directory>
sections +inaccess.conf
, or from defaults in +srm.conf
, which actually behaves for most purposes almost +exactly like<Directory />
).Finally, after having served a request which involved reading -
.htaccess
files, we need to discard the storage allocated +.htaccess
files, we need to discard the storage allocated for handling them. That is solved the same way it is solved wherever else similar problems come up, by tying those structures to the -per-transaction resource pool.+per-transaction resource pool.
-
Per-directory configuration structures
+Per-directory configuration structures
-Let's look out how all of this plays out inmod_mime.c
, +Let's look out how all of this plays out inmod_mime.c
, which defines the file typing handler which emulates the NCSA server's behavior of determining file types from suffixes. What we'll be looking at, here, is the code which implements the -AddType
andAddEncoding
commands. These -commands can appear in.htaccess
files, so they must be +AddType
andAddEncoding
commands. These +commands can appear in.htaccess
files, so they must be handled in the module's private per-directory data, which in fact, -consists of two separatetable
s for MIME types and +consists of two separatetable
s for MIME types and encoding information, and is declared as follows: -+When the server is reading a configuration file, or -typedef struct { table *forced_types; /* Additional AddTyped stuff */ table *encoding_types; /* Added with AddEncoding... */ } mime_dir_config; -+<Directory>
section, which includes one of the MIME -module's commands, it needs to create amime_dir_config
+<Directory>
section, which includes one of the MIME +module's commands, it needs to create amime_dir_config
structure, so those commands have something to act on. It does this by invoking the function it finds in the module's `create per-dir config slot', with two arguments: the name of the directory to which -this configuration information applies (orNULL
for -srm.conf
), and a pointer to a resource pool in which the -allocation should happen.+this configuration information applies (or
NULL
for +srm.conf
), and a pointer to a resource pool in which the +allocation should happen.-(If we are reading a
.htaccess
file, that resource pool +(If we are reading a.htaccess
file, that resource pool is the per-request resource pool for the request; otherwise it is a resource pool which is used for configuration data, and cleared on restarts. Either way, it is important for the structure being created to vanish when the pool is cleared, by registering a cleanup on the -pool if necessary).+pool if necessary).
For the MIME module, the per-dir config creation function just -
palloc
s the structure above, and a creates a couple of -table
s to fill it. That looks like this: +palloc
s the structure above, and a creates a couple of +table
s to fill it. That looks like this: -+-Now, suppose we've just read in avoid *create_mime_dir_config (pool *p, char *dummy) { mime_dir_config *new = @@ -786,15 +786,15 @@ void *create_mime_dir_config (pool *p, char *dummy) return new; } -+.htaccess
file. We +Now, suppose we've just read in a.htaccess
file. We already have the per-directory configuration structure for the next -directory up in the hierarchy. If the.htaccess
file we -just read in didn't have anyAddType
or -AddEncoding
commands, its per-directory config structure +directory up in the hierarchy. If the.htaccess
file we +just read in didn't have anyAddType
or +AddEncoding
commands, its per-directory config structure for the MIME module is still valid, and we can just use it. -Otherwise, we need to merge the two structures somehow.+Otherwise, we need to merge the two structures somehow.
To do that, the server invokes the module's per-directory config merge function, if one is present. That function takes three arguments: @@ -803,7 +803,7 @@ allocate the result. For the MIME module, all that needs to be done is overlay the tables from the new per-directory config structure with those from the parent: -
+As a note --- if there is no per-directory merge function present, the server will just use the subdirectory's configuration info, and ignore the parent's. For some modules, that works just fine (e.g., for the includes module, whose per-directory configuration information -consists solely of the state of thevoid *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv) { mime_dir_config *parent_dir = (mime_dir_config *)parent_dirv; @@ -818,63 +818,63 @@ void *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv) return new; } -+XBITHACK
), and for +consists solely of the state of theXBITHACK
), and for those modules, you can just not declare one, and leave the -corresponding structure slot in the module itselfNULL
.+corresponding structure slot in the module itself
NULL
.-
Command handling
+Command handling
Now that we have these structures, we need to be able to figure out how to fill them. That involves processing the actual -AddType
andAddEncoding
commands. To find -commands, the server looks in the module'scommand table
. +AddType
andAddEncoding
commands. To find +commands, the server looks in the module'scommand table
. That table contains information on how many arguments the commands take, and in what formats, where it is permitted, and so forth. That information is sufficient to allow the server to invoke most command-handling functions with pre-parsed arguments. Without further -ado, let's look at theAddType
command handler, which -looks like this (theAddEncoding
command looks basically +ado, let's look at theAddType
command handler, which +looks like this (theAddEncoding
command looks basically the same, and won't be shown here): -+This command handler is unusually simple. As you can see, it takes four arguments, two of which are pre-parsed arguments, the third being the per-directory configuration structure for the module in question, -and the fourth being a pointer to achar *add_type(cmd_parms *cmd, mime_dir_config *m, char *ct, char *ext) { if (*ext == '.') ++ext; table_set (m->forced_types, ext, ct); return NULL; } -+cmd_parms
structure. +and the fourth being a pointer to acmd_parms
structure. That structure contains a bunch of arguments which are frequently of use to some, but not all, commands, including a resource pool (from which memory can be allocated, and to which cleanups should be tied), and the (virtual) server being configured, from which the module's -per-server configuration data can be obtained if required.+per-server configuration data can be obtained if required.
Another way in which this particular command handler is unusually simple is that there are no error conditions which it can encounter. If there were, it could return an error message instead of -
NULL
; this causes an error to be printed out on the -server'sstderr
, followed by a quick exit, if it is in -the main config files; for a.htaccess
file, the syntax +NULL
; this causes an error to be printed out on the +server'sstderr
, followed by a quick exit, if it is in +the main config files; for a.htaccess
file, the syntax error is logged in the server error log (along with an indication of where it came from), and the request is bounced with a server error -response (HTTP error status, code 500).+response (HTTP error status, code 500).
The MIME module's command table has entries for these commands, which look like this: -
+The entries in these tables are: -command_rec mime_cmds[] = { { "AddType", add_type, NULL, OR_FILEINFO, TAKE2, "a mime type followed by a file extension" }, @@ -882,54 +882,54 @@ command_rec mime_cmds[] = { "an encoding (e.g., gzip), followed by a file extension" }, { NULL } }; -+-
Finally, having set this all up, we have to use it. This is ultimately done in the module's handlers, specifically for its file-typing handler, which looks more or less like this; note that the per-directory configuration structure is extracted from the -- The name of the command -
- The function which handles it -
- a
(void *)
pointer, which is passed in the -cmd_parms
structure to the command handler --- ++
+- The name of the command +
- The function which handles it +
- a
(void *)
pointer, which is passed in the +cmd_parms
structure to the command handler --- this is useful in case many similar commands are handled by the same function. -- A bit mask indicating where the command may appear. There are - mask bits corresponding to each
AllowOverride
- option, and an additional mask bit,RSRC_CONF
, +- A bit mask indicating where the command may appear. There are + mask bits corresponding to each
AllowOverride
+ option, and an additional mask bit,RSRC_CONF
, indicating that the command may appear in the server's own - config files, but not in any.htaccess
+ config files, but not in any.htaccess
file. -- A flag indicating how many arguments the command handler wants +
- A flag indicating how many arguments the command handler wants pre-parsed, and how they should be passed in. -
TAKE2
indicates two pre-parsed arguments. Other - options areTAKE1
, which indicates one pre-parsed - argument,FLAG
, which indicates that the argument - should beOn
orOff
, and is passed in - as a boolean flag,RAW_ARGS
, which causes the +TAKE2
indicates two pre-parsed arguments. Other + options areTAKE1
, which indicates one pre-parsed + argument,FLAG
, which indicates that the argument + should beOn
orOff
, and is passed in + as a boolean flag,RAW_ARGS
, which causes the server to give the command the raw, unparsed arguments (everything but the command name itself). There is also -ITERATE
, which means that the handler looks the - same asTAKE1
, but that if multiple arguments are +ITERATE
, which means that the handler looks the + same asTAKE1
, but that if multiple arguments are present, it should be called multiple times, and finally -ITERATE2
, which indicates that the command handler - looks like aTAKE2
, but if more arguments are +ITERATE2
, which indicates that the command handler + looks like aTAKE2
, but if more arguments are present, then it should be called multiple times, holding the first argument constant. -- Finally, we have a string which describes the arguments that +
- Finally, we have a string which describes the arguments that should be present. If the arguments in the actual config file are not as required, this string will be used to help give a more specific error message. (You can safely leave this -
NULL
). -NULL
). +request_rec
's per-directory configuration vector by using -theget_module_config
function. +request_rec
's per-directory configuration vector by using +theget_module_config
function. -+-int find_ct(request_rec *r) { int i; @@ -965,9 +965,9 @@ int find_ct(request_rec *r) return OK; } -+Side notes --- per-server configuration, virtual servers, etc.
+Side notes --- per-server configuration, virtual servers, etc.
The basic ideas behind per-server module configuration are basically the same as those for per-directory configuration; there is a creation @@ -976,17 +976,17 @@ virtual server has partially overridden the base server configuration, and a combined structure must be computed. (As with per-directory configuration, the default if no merge function is specified, and a module is configured in some virtual server, is that the base -configuration is simply ignored).+configuration is simply ignored).
The only substantial difference is that when a command needs to configure the per-server private module data, it needs to go to the -
cmd_parms
data to get at it. Here's an example, from the +cmd_parms
data to get at it. Here's an example, from the alias module, which also indicates how a syntax error can be returned (note that the per-directory configuration argument to the command handler is declared as a dummy, since the module doesn't actually have per-directory config data): -+- + diff --git a/docs/manual/dns-caveats.html b/docs/manual/dns-caveats.html index 66d0c22c99..4e9719df3b 100644 --- a/docs/manual/dns-caveats.html +++ b/docs/manual/dns-caveats.html @@ -1,7 +1,7 @@ - -char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url) { server_rec *s = cmd->server; @@ -999,6 +999,6 @@ char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url) new->fake = f; new->real = url; return NULL; } -+Issues Regarding DNS and Apache - + +Issues Regarding DNS and Apache + -Issues Regarding DNS and Apache
+Issues Regarding DNS and Apache
-This page could be summarized with the statement: don't require -Apache to use DNS for any parsing of the configuration files. +
This page could be summarized with the statement: don't require +Apache to use DNS for any parsing of the configuration files. If Apache has to use DNS to parse the configuration files then your server may be subject to reliability problems (it might not boot), or denial and theft of service attacks (including users able to steal hits @@ -25,35 +25,35 @@ from other users). Consider this configuration snippet: -
-++<VirtualHost www.abc.dom> ServerAdmin webgirl@abc.dom DocumentRoot /www/abc </VirtualHost> -In order for Apache to function properly it absolutely needs +
In order for Apache to function properly it absolutely needs to have two pieces of information about each virtual host: the -
ServerName
+ServerName
and at least one IP address that the server responds to. This example does not include the IP address, so Apache -must use DNS to find the address ofwww.abc.dom
. If for +must use DNS to find the address ofwww.abc.dom
. If for some reason DNS is not available at the time your server is parsing its -config file, then this virtual host will not be configured. It +config file, then this virtual host will not be configured. It won't be able to respond to any hits to this virtual host (prior to Apache version 1.2 the server would not even boot). -Suppose that
www.abc.dom
has address 10.0.0.1. Then +Suppose that
www.abc.dom
has address 10.0.0.1. Then consider this configuration snippet: --++<VirtualHost 10.0.0.1> ServerAdmin webgirl@abc.dom DocumentRoot /www/abc </VirtualHost> -Now Apache needs to use reverse DNS to find the
ServerName
+Now Apache needs to use reverse DNS to find the
ServerName
for this virtualhost. If that reverse lookup fails then it will partially disable the virtualhost (prior to Apache version 1.2 the server would not even boot). If the virtual host is name-based then it will effectively @@ -61,108 +61,108 @@ be totally disabled, but if it is IP-based then it will mostly work. However if Apache should ever have to generate a full URL for the server which includes the server name then it will fail to generate a valid URL. -Here is a snippet that avoids both of these problems. +
Here is a snippet that avoids both of these problems. -
++<VirtualHost 10.0.0.1> ServerName www.abc.dom ServerAdmin webgirl@abc.dom DocumentRoot /www/abc </VirtualHost> -Denial of Service
-There are (at least) two forms that denial of service can come in. +
There are (at least) two forms that denial of service can come in. If you are running a version of Apache prior to version 1.2 then your server will not even boot if one of the two DNS lookups mentioned above fails for any of your virtual hosts. In some cases this DNS lookup may -not even be under your control. For example, if
abc.dom
+not even be under your control. For example, ifabc.dom
is one of your customers and they control their own DNS then they can force your (pre-1.2) server to fail while booting simply by deleting the -www.abc.dom
record. +www.abc.dom
record. -Another form is far more insidious. Consider this configuration +
Another form is far more insidious. Consider this configuration snippet: -
-++<VirtualHost www.abc.dom> ServerAdmin webgirl@abc.dom DocumentRoot /www/abc </VirtualHost> -+ ++- -<VirtualHost www.def.dom> ServerAdmin webguy@def.dom DocumentRoot /www/def </VirtualHost> -Suppose that you've assigned 10.0.0.1 to
www.abc.dom
and -10.0.0.2 towww.def.dom
. Furthermore, suppose that -def.com
has control of their own DNS. With this config -you have putdef.com
into a position where they can steal -all traffic destined toabc.com
. To do so, all they have to -do is setwww.def.dom
to 10.0.0.1. +Suppose that you've assigned 10.0.0.1 to
www.abc.dom
and +10.0.0.2 towww.def.dom
. Furthermore, suppose that +def.com
has control of their own DNS. With this config +you have putdef.com
into a position where they can steal +all traffic destined toabc.com
. To do so, all they have to +do is setwww.def.dom
to 10.0.0.1. Since they control their own DNS you can't stop them from pointing the -www.def.com
record wherever they wish. +www.def.com
record wherever they wish. -Requests coming in to 10.0.0.1 (including all those where users typed -in URLs of the form
http://www.abc.dom/whatever
) will all be -served by thedef.com
virtual host. To better understand why +Requests coming in to 10.0.0.1 (including all those where users typed +in URLs of the form
http://www.abc.dom/whatever
) will all be +served by thedef.com
virtual host. To better understand why this happens requires a more in-depth discussion of how Apache matches up incoming requests with the virtual host that will serve it. A rough -document describing this is available. +document describing this is available.The "main server" Address
-The addition of name-based virtual host -support in Apache 1.1 requires Apache to know the IP address(es) of +
The addition of name-based virtual host +support in Apache 1.1 requires Apache to know the IP address(es) of the host that httpd is running on. To get this address it uses either -the global
ServerName
(if present) or calls the C function -gethostname
(which should return the same as typing +the globalServerName
(if present) or calls the C function +gethostname
(which should return the same as typing "hostname" at the command prompt). Then it performs a DNS lookup on this address. At present there is no way to avoid this lookup. -If you fear that this lookup might fail because your DNS server is down -then you can insert the hostname in
/etc/hosts
(where you +If you fear that this lookup might fail because your DNS server is down +then you can insert the hostname in
/etc/hosts
(where you probably already have it so that the machine can boot properly). Then -ensure that your machine is configured to use/etc/hosts
+ensure that your machine is configured to use/etc/hosts
in the event that DNS fails. Depending on what OS you are using this -might be accomplished by editing/etc/resolv.conf
, or maybe -/etc/nsswitch.conf
. +might be accomplished by editing/etc/resolv.conf
, or maybe +/etc/nsswitch.conf
. -If your server doesn't have to perform DNS for any other reason +
If your server doesn't have to perform DNS for any other reason then you might be able to get away with running Apache with the -
HOSTRESORDER
environment variable set to "local". This all +HOSTRESORDER
environment variable set to "local". This all depends on what OS and resolver libraries you are using. It also affects -CGIs unless you usemod_env
+CGIs unless you usemod_env
to control the environment. It's best to consult the man pages or FAQs for your OS. -Tips to Avoid these problems
+Tips to Avoid these problems
--
- use IP addresses in
<VirtualHost>
-- use IP addresses in
Listen
-- use IP addresses in
BindAddress
-- ensure all virtual hosts have an explicit
ServerName
-- create a
<VirtualHost _default_:*>
server that ++
+- use IP addresses in
<VirtualHost>
+- use IP addresses in
Listen
+- use IP addresses in
BindAddress
+- ensure all virtual hosts have an explicit
ServerName
+- create a
<VirtualHost _default_:*>
server that has no pages to serve -Appendix: Future Directions
-The situation regarding DNS is highly undesirable. For Apache +
The situation regarding DNS is highly undesirable. For Apache 1.2 we've attempted to make the server at least continue booting in the event of failed DNS, but it might not be the best we can do. In any event requiring the use of explicit IP addresses in -configuration files is highly undesirable in today's Internet where renumbering - is a necessity. +configuration files is highly undesirable in today's Internet where renumbering + is a necessity. -
A possible work around to the theft of service attack described above +
A possible work around to the theft of service attack described above would be to perform a reverse DNS lookup on the ip address returned by the forward lookup and compare the two names. In the event of a mismatch the virtualhost would be disabled. This would require reverse DNS to be @@ -170,14 +170,14 @@ configured properly (which is something that most admins are familiar with because of the common use of "double-reverse" DNS lookups by FTP servers and TCP wrappers). -
In any event it doesn't seem possible to reliably boot a virtual-hosted +
In any event it doesn't seem possible to reliably boot a virtual-hosted web server when DNS has failed unless IP addresses are used. Partial solutions such as disabling portions of the configuration might be worse than not booting at all depending on what the webserver is supposed to accomplish. -
As HTTP/1.1 is deployed and browsers and proxies start issuing the -
Host
header it will become possible to avoid the use of +As HTTP/1.1 is deployed and browsers and proxies start issuing the +
Host
header it will become possible to avoid the use of IP-based virtual hosts entirely. In this event a webserver has no requirement to do DNS lookups during configuration. But as of March 1997 these features have not been deployed widely enough to be put into use on diff --git a/docs/manual/env.html b/docs/manual/env.html index 0ea86178a6..6fd778adaa 100644 --- a/docs/manual/env.html +++ b/docs/manual/env.html @@ -13,7 +13,7 @@ ALINK="#FF0000" > -Special Purpose Environment Variables
+Special Purpose Environment Variables
Interoperability problems have led to the introduction of mechanisms to modify the way Apache behaves when talking to particular clients. To make these mechanisms as flexible as possible, they @@ -38,7 +38,7 @@ when given an HTTP/1.1 response, and this can be used to interoperate with them.
downgrade-1.0
-This forces the request to be treated as a HTTP/1.0 request even if it +
This forces the request to be treated as a HTTP/1.0 request even if it was in a later dialect. diff --git a/docs/manual/env.html.en b/docs/manual/env.html.en index 0ea86178a6..6fd778adaa 100644 --- a/docs/manual/env.html.en +++ b/docs/manual/env.html.en @@ -13,7 +13,7 @@ ALINK="#FF0000" > -
Special Purpose Environment Variables
+Special Purpose Environment Variables
Interoperability problems have led to the introduction of mechanisms to modify the way Apache behaves when talking to particular clients. To make these mechanisms as flexible as possible, they @@ -38,7 +38,7 @@ when given an HTTP/1.1 response, and this can be used to interoperate with them.
downgrade-1.0
-This forces the request to be treated as a HTTP/1.0 request even if it +
This forces the request to be treated as a HTTP/1.0 request even if it was in a later dialect. diff --git a/docs/manual/handler.html b/docs/manual/handler.html index 8059216112..504dd09ebf 100644 --- a/docs/manual/handler.html +++ b/docs/manual/handler.html @@ -13,127 +13,127 @@ ALINK="#FF0000" > -
Apache's Handler Use
+Apache's Handler Use
What is a Handler
-A "handler" is an internal Apache representation of the action to be +
A "handler" is an internal Apache representation of the action to be performed when a file is called. Generally, files have implicit handlers, based on the file type. Normally, all files are simply served by the server, but certain file typed are "handled" separately. For example, you may use a type of -"application/x-httpd-cgi" to invoke CGI scripts.
+"application/x-httpd-cgi" to invoke CGI scripts. -Apache 1.1 adds the additional ability to use handlers +
Apache 1.1 adds the additional ability to use handlers explicitly. Either based on filename extensions or on location, these handlers are unrelated to file type. This is advantageous both because it is a more elegant solution, but it also allows for both a type -and a handler to be associated with a file.
+and a handler to be associated with a file. -Handlers can either be built into the server or to a module, or -they can be added with the Action directive. The built-in -handlers in the standard distribution are as follows:
+Handlers can either be built into the server or to a module, or +they can be added with the Action directive. The built-in +handlers in the standard distribution are as follows:
--
-- send-as-is: +
+
+ (mod_negotiation) +- send-as-is: Send file with HTTP headers as is. - (mod_asis) -
- cgi-script: + (mod_asis) +
- cgi-script: Treat the file as a CGI script. - (mod_cgi) -
- imap-file: + (mod_cgi) +
- imap-file: Imagemap rule file. - (mod_imap) -
- server-info: + (mod_imap) +
- server-info: Get the server's configuration information - (mod_info) -
- server-parsed: + (mod_info) +
- server-parsed: Parse for server-side includes - (mod_include) -
- server-status: + (mod_include) +
- server-status: Get the server's status report - (mod_status) -
- type-map: + (mod_status) +
- type-map: Parse as a type map file for content negotiation - (mod_negotiation) -
+
Directives
--
+- AddHandler -
- SetHandler -
+
-- AddHandler +
- SetHandler +
+
-AddHandler
+AddHandler
-Syntax: <AddHandler handler-name extension>
-Context: server config, virtual host, directory, .htaccess
-Status: Base
-Module: mod_mime +Syntax: <AddHandler handler-name extension>
+Context: server config, virtual host, directory, .htaccess
+Status: Base
+Module: mod_mime -AddHandler maps the filename extension extension to the -handler handler-name. For example, to activate CGI scripts -with the file extension "
.cgi
", you might use: -+-AddHandler maps the filename extension extension to the +handler handler-name. For example, to activate CGI scripts +with the file extension "
.cgi
", you might use: +AddHandler cgi-script cgi -+Once that has been put into your srm.conf or httpd.conf file, any -file ending with "
+.cgi
" will be treated as a CGI -program.Once that has been put into your srm.conf or httpd.conf file, any +file ending with "
-.cgi
" will be treated as a CGI +program.
+
-SetHandler
+SetHandler
-Syntax: <SetHandler handler-name>
-Context: directory, .htaccess
-Status: Base
-Module: mod_mime +Syntax: <SetHandler handler-name>
+Context: directory, .htaccess
+Status: Base
+Module: mod_mime -When placed into an
.htaccess
file or a -<Directory>
or<Location>
section, +When placed into an
.htaccess
file or a +<Directory>
or<Location>
section, this directive forces all matching files to be parsed through the -handler given by handler-name. For example, if you had a +handler given by handler-name. For example, if you had a directory you wanted to be parsed entirely as imagemap rule files, regardless of extension, you might put the following into an -.htaccess
file in that directory: -++.htaccess
file in that directory: +SetHandler imap-file --Another example: if you wanted to have the server display a status -report whenever a URL of
http://servername/status
was +Another example: if you wanted to have the server display a status +report whenever a URL of
http://servername/status
was called, you might put the following into access.conf: -+-<Location /status> SetHandler server-status </Location> -+
+
Programmer's Note
-In order to implement the handler features, an addition has been -made to the Apache API that you may wish to +
In order to implement the handler features, an addition has been +made to the Apache API that you may wish to make use of. Specifically, a new record has been added to the -
-request_rec
structure:++request_rec
structure: +char *handler --If you wish to have your module engage a handler, you need only to -set
r->handler
to the name of the handler at any time -prior to theinvoke_handler
stage of the +If you wish to have your module engage a handler, you need only to +set
+type name-space. diff --git a/docs/manual/handler.html.en b/docs/manual/handler.html.en index 8059216112..504dd09ebf 100644 --- a/docs/manual/handler.html.en +++ b/docs/manual/handler.html.en @@ -13,127 +13,127 @@ ALINK="#FF0000" > -r->handler
to the name of the handler at any time +prior to theinvoke_handler
stage of the request. Handlers are implemented as they were before, albeit using the handler name instead of a content type. While it is not necessary, the naming convention for handlers is to use a dash-separated word, with no slashes, so as to not invade the media -type name-space.Apache's Handler Use
+Apache's Handler Use
What is a Handler
-A "handler" is an internal Apache representation of the action to be +
A "handler" is an internal Apache representation of the action to be performed when a file is called. Generally, files have implicit handlers, based on the file type. Normally, all files are simply served by the server, but certain file typed are "handled" separately. For example, you may use a type of -"application/x-httpd-cgi" to invoke CGI scripts.
+"application/x-httpd-cgi" to invoke CGI scripts. -Apache 1.1 adds the additional ability to use handlers +
Apache 1.1 adds the additional ability to use handlers explicitly. Either based on filename extensions or on location, these handlers are unrelated to file type. This is advantageous both because it is a more elegant solution, but it also allows for both a type -and a handler to be associated with a file.
+and a handler to be associated with a file. -Handlers can either be built into the server or to a module, or -they can be added with the Action directive. The built-in -handlers in the standard distribution are as follows:
+Handlers can either be built into the server or to a module, or +they can be added with the Action directive. The built-in +handlers in the standard distribution are as follows:
--
-- send-as-is: +
+
+ (mod_negotiation) +- send-as-is: Send file with HTTP headers as is. - (mod_asis) -
- cgi-script: + (mod_asis) +
- cgi-script: Treat the file as a CGI script. - (mod_cgi) -
- imap-file: + (mod_cgi) +
- imap-file: Imagemap rule file. - (mod_imap) -
- server-info: + (mod_imap) +
- server-info: Get the server's configuration information - (mod_info) -
- server-parsed: + (mod_info) +
- server-parsed: Parse for server-side includes - (mod_include) -
- server-status: + (mod_include) +
- server-status: Get the server's status report - (mod_status) -
- type-map: + (mod_status) +
- type-map: Parse as a type map file for content negotiation - (mod_negotiation) -
+
Directives
--
+- AddHandler -
- SetHandler -
+
-- AddHandler +
- SetHandler +
+
-AddHandler
+AddHandler
-Syntax: <AddHandler handler-name extension>
-Context: server config, virtual host, directory, .htaccess
-Status: Base
-Module: mod_mime +Syntax: <AddHandler handler-name extension>
+Context: server config, virtual host, directory, .htaccess
+Status: Base
+Module: mod_mime -AddHandler maps the filename extension extension to the -handler handler-name. For example, to activate CGI scripts -with the file extension "
.cgi
", you might use: -+-AddHandler maps the filename extension extension to the +handler handler-name. For example, to activate CGI scripts +with the file extension "
.cgi
", you might use: +AddHandler cgi-script cgi -+Once that has been put into your srm.conf or httpd.conf file, any -file ending with "
+.cgi
" will be treated as a CGI -program.Once that has been put into your srm.conf or httpd.conf file, any +file ending with "
-.cgi
" will be treated as a CGI +program.
+
-SetHandler
+SetHandler
-Syntax: <SetHandler handler-name>
-Context: directory, .htaccess
-Status: Base
-Module: mod_mime +Syntax: <SetHandler handler-name>
+Context: directory, .htaccess
+Status: Base
+Module: mod_mime -When placed into an
.htaccess
file or a -<Directory>
or<Location>
section, +When placed into an
.htaccess
file or a +<Directory>
or<Location>
section, this directive forces all matching files to be parsed through the -handler given by handler-name. For example, if you had a +handler given by handler-name. For example, if you had a directory you wanted to be parsed entirely as imagemap rule files, regardless of extension, you might put the following into an -.htaccess
file in that directory: -++.htaccess
file in that directory: +SetHandler imap-file --Another example: if you wanted to have the server display a status -report whenever a URL of
http://servername/status
was +Another example: if you wanted to have the server display a status +report whenever a URL of
http://servername/status
was called, you might put the following into access.conf: -+-<Location /status> SetHandler server-status </Location> -+
+
Programmer's Note
-In order to implement the handler features, an addition has been -made to the Apache API that you may wish to +
In order to implement the handler features, an addition has been +made to the Apache API that you may wish to make use of. Specifically, a new record has been added to the -
-request_rec
structure:++request_rec
structure: +char *handler --If you wish to have your module engage a handler, you need only to -set
r->handler
to the name of the handler at any time -prior to theinvoke_handler
stage of the +If you wish to have your module engage a handler, you need only to +set
+type name-space. diff --git a/docs/manual/install.html b/docs/manual/install.html index 6052841af2..e799ad0bac 100644 --- a/docs/manual/install.html +++ b/docs/manual/install.html @@ -36,7 +36,7 @@ for how to compile the server.r->handler
to the name of the handler at any time +prior to theinvoke_handler
stage of the request. Handlers are implemented as they were before, albeit using the handler name instead of a content type. While it is not necessary, the naming convention for handlers is to use a dash-separated word, with no slashes, so as to not invade the media -type name-space.Compiling Apache
Compiling Apache consists of three steps: Firstly select which Apache -modules you want to include into the server. Secondly create a +modules you want to include into the server. Secondly create a configuration for your operating system. Thirdly compile the executable.@@ -111,7 +111,7 @@ The modules we place in the Apache distribution are the ones we have tested and are used regularly by various members of the Apache development group. Additional modules contributed by members or third parties with specific needs or functions are available at <URL:http://www.apache.org/dist/contrib/modules/>. +HREF="http://www.apache.org/dist/contrib/modules/"><URL:http://www.apache.org/dist/contrib/modules/>. There are instructions on that page for linking these modules into the core Apache code. @@ -126,11 +126,11 @@ designed to be configured and run from the same set of directories where it is compiled. If you want to run it from somewhere else, make a directory and copy the
conf
,logs
andicons
directories into it. In either case you should -read the security tips +read the security tips describing how to set the permissions on the server root directory.The next step is to edit the configuration files for the server. This -consists of setting up various directives in up to three +consists of setting up various directives in up to three central configuration files. By default, these files are located in the
conf
directory and are calledsrm.conf
,access.conf
andhttpd.conf
. To help you get @@ -188,7 +188,7 @@ port of 80, a suitable URL to enter into your browser isNote that when the server starts it will create a number of -child processes to handle the requests. If you started Apache +child processes to handle the requests. If you started Apache as the root user, the parent process will continue to run as root while the children will change to the user as given in the httpd.conf file. @@ -214,7 +214,7 @@ this will be located in the file
error_log
in the If you want your server to continue running after a system reboot, you should add a call tohttpd
to your system startup files (typicallyrc.local
or a file in an -rc.N
directory). This will start Apache as root. +rc.N
directory). This will start Apache as root. Before doing this ensure that your server is properly configured for security and access restrictions. diff --git a/docs/manual/install.html.en b/docs/manual/install.html.en index 6052841af2..e799ad0bac 100644 --- a/docs/manual/install.html.en +++ b/docs/manual/install.html.en @@ -36,7 +36,7 @@ for how to compile the server.Compiling Apache
Compiling Apache consists of three steps: Firstly select which Apache -modules you want to include into the server. Secondly create a +modules you want to include into the server. Secondly create a configuration for your operating system. Thirdly compile the executable.@@ -111,7 +111,7 @@ The modules we place in the Apache distribution are the ones we have tested and are used regularly by various members of the Apache development group. Additional modules contributed by members or third parties with specific needs or functions are available at <URL:http://www.apache.org/dist/contrib/modules/>. +HREF="http://www.apache.org/dist/contrib/modules/"><URL:http://www.apache.org/dist/contrib/modules/>. There are instructions on that page for linking these modules into the core Apache code. @@ -126,11 +126,11 @@ designed to be configured and run from the same set of directories where it is compiled. If you want to run it from somewhere else, make a directory and copy the
conf
,logs
andicons
directories into it. In either case you should -read the security tips +read the security tips describing how to set the permissions on the server root directory.The next step is to edit the configuration files for the server. This -consists of setting up various directives in up to three +consists of setting up various directives in up to three central configuration files. By default, these files are located in the
conf
directory and are calledsrm.conf
,access.conf
andhttpd.conf
. To help you get @@ -188,7 +188,7 @@ port of 80, a suitable URL to enter into your browser isNote that when the server starts it will create a number of -child processes to handle the requests. If you started Apache +child processes to handle the requests. If you started Apache as the root user, the parent process will continue to run as root while the children will change to the user as given in the httpd.conf file. @@ -214,7 +214,7 @@ this will be located in the file
error_log
in the If you want your server to continue running after a system reboot, you should add a call tohttpd
to your system startup files (typicallyrc.local
or a file in an -rc.N
directory). This will start Apache as root. +rc.N
directory). This will start Apache as root. Before doing this ensure that your server is properly configured for security and access restrictions. diff --git a/docs/manual/invoking.html b/docs/manual/invoking.html index 708c63de29..d718c2f89c 100644 --- a/docs/manual/invoking.html +++ b/docs/manual/invoking.html @@ -13,84 +13,84 @@ ALINK="#FF0000" > -Starting Apache
+Starting Apache
Invoking Apache
-Thehttpd
program is usually run as a daemon which executes +Thehttpd
program is usually run as a daemon which executes continuously, handling requests. It is possible to invoke Apache by -the Internet daemoninetd
each time a connection to the HTTP +the Internet daemoninetd
each time a connection to the HTTP service is made (use the ServerType directive) but this is not recommended.Command line options
The following options are recognized on the httpd command line: --
-d
serverroot -- Set the initial value for the +
+
+-d
serverroot +- Set the initial value for the ServerRoot variable to -serverroot. This can be overridden by the ServerRoot command in the -configuration file. The default is
/usr/local/apache
. +serverroot. This can be overridden by the ServerRoot command in the +configuration file. The default is/usr/local/apache
. --f
config -- Execute the commands in the file config on startup. If -config does not begin with a
/
, then it is taken to be a +-f
config +- Execute the commands in the file config on startup. If +config does not begin with a
/
, then it is taken to be a path relative to the ServerRoot. The -default isconf/httpd.conf
. +default isconf/httpd.conf
. --X
-- Run in single-process mode, for internal debugging purposes only; the -daemon does not detach from the terminal or fork any children. Do NOT +
-X
+- Run in single-process mode, for internal debugging purposes only; the +daemon does not detach from the terminal or fork any children. Do NOT use this mode to provide ordinary web service. -
-v
-- Print the version of httpd and its build date, and then exit. +
-v
+- Print the version of httpd and its build date, and then exit. -
-V
-- Print the base version of httpd, its sub-version if defined, its +
-V
+- Print the base version of httpd, its sub-version if defined, its build date, and a list of compile time settings which influence the behavior and performance of the apache server (e.g., -D USE_MMAP_FILES), then exit. -
-h
-- Give a list of directives together with expected arguments and +
-h
+- Give a list of directives together with expected arguments and places where the directive is valid. (New in Apache 1.2) -
-l
-- Give a list of all modules compiled into the server. +
-l
+- Give a list of all modules compiled into the server. -
-?
-- Print a list of the httpd options, and then exit. -
-?
+- Print a list of the httpd options, and then exit. +
Configuration files
The server will read three files for configuration directives. Any directive may appear in any of these files. The the names of these files are taken to be relative to the server root; this is set by the ServerRoot directive, or the --d
command line flag. +-d
command line flag. Conventionally, the files are: --
However, these conventions need not be adhered to. -conf/httpd.conf
-- Contains directives that control the operation of the server daemon. -The filename may be overridden with the
-f
command line flag. ++
+conf/httpd.conf
+- Contains directives that control the operation of the server daemon. +The filename may be overridden with the
-f
command line flag. -conf/srm.conf
-- Contains directives that control the specification of documents that +
conf/srm.conf
+- Contains directives that control the specification of documents that the server can provide to clients. The filename may be overridden with the ResourceConfig directive. -
conf/access.conf
-- Contains directives that control access to documents. +
conf/access.conf
+- Contains directives that control access to documents. The filename may be overridden with the AccessConfig directive. -
+
The server also reads a file containing mime document types; the filename is set by the TypesConfig directive, -and is
conf/mime.types
by default. +and isconf/mime.types
by default.Log files
security warning
@@ -102,25 +102,25 @@ the consequences; see the security tips document for details.pid file
On daemon startup, it saves the process id of the parent httpd process to -the filelogs/httpd.pid
. This filename can be changed with the +the filelogs/httpd.pid
. This filename can be changed with the PidFile directive. The process-id is for use by the administrator in restarting and terminating the daemon; A HUP or USR1 signal causes the daemon to re-read its configuration files and a TERM signal causes it to die gracefully. For more information -see the Stopping and Restarting page. -+see the Stopping and Restarting page. +
If the process dies (or is killed) abnormally, then it will be necessary to kill the children httpd processes.
Error log
-The server will log error messages to a log file,logs/error_log
+The server will log error messages to a log file,logs/error_log
by default. The filename can be set using the ErrorLog directive; different error logs can be set for different virtual hosts.Transfer log
The server will typically log each request to a transfer file, -logs/access_log
by default. The filename can be set using a +logs/access_log
by default. The filename can be set using a TransferLog directive; different transfer logs can be set for different virtual hosts. diff --git a/docs/manual/invoking.html.en b/docs/manual/invoking.html.en index 708c63de29..d718c2f89c 100644 --- a/docs/manual/invoking.html.en +++ b/docs/manual/invoking.html.en @@ -13,84 +13,84 @@ ALINK="#FF0000" > -Starting Apache
+Starting Apache
Invoking Apache
-Thehttpd
program is usually run as a daemon which executes +Thehttpd
program is usually run as a daemon which executes continuously, handling requests. It is possible to invoke Apache by -the Internet daemoninetd
each time a connection to the HTTP +the Internet daemoninetd
each time a connection to the HTTP service is made (use the ServerType directive) but this is not recommended.Command line options
The following options are recognized on the httpd command line: --
-d
serverroot -- Set the initial value for the +
+
+-d
serverroot +- Set the initial value for the ServerRoot variable to -serverroot. This can be overridden by the ServerRoot command in the -configuration file. The default is
/usr/local/apache
. +serverroot. This can be overridden by the ServerRoot command in the +configuration file. The default is/usr/local/apache
. --f
config -- Execute the commands in the file config on startup. If -config does not begin with a
/
, then it is taken to be a +-f
config +- Execute the commands in the file config on startup. If +config does not begin with a
/
, then it is taken to be a path relative to the ServerRoot. The -default isconf/httpd.conf
. +default isconf/httpd.conf
. --X
-- Run in single-process mode, for internal debugging purposes only; the -daemon does not detach from the terminal or fork any children. Do NOT +
-X
+- Run in single-process mode, for internal debugging purposes only; the +daemon does not detach from the terminal or fork any children. Do NOT use this mode to provide ordinary web service. -
-v
-- Print the version of httpd and its build date, and then exit. +
-v
+- Print the version of httpd and its build date, and then exit. -
-V
-- Print the base version of httpd, its sub-version if defined, its +
-V
+- Print the base version of httpd, its sub-version if defined, its build date, and a list of compile time settings which influence the behavior and performance of the apache server (e.g., -D USE_MMAP_FILES), then exit. -
-h
-- Give a list of directives together with expected arguments and +
-h
+- Give a list of directives together with expected arguments and places where the directive is valid. (New in Apache 1.2) -
-l
-- Give a list of all modules compiled into the server. +
-l
+- Give a list of all modules compiled into the server. -
-?
-- Print a list of the httpd options, and then exit. -
-?
+- Print a list of the httpd options, and then exit. +
Configuration files
The server will read three files for configuration directives. Any directive may appear in any of these files. The the names of these files are taken to be relative to the server root; this is set by the ServerRoot directive, or the --d
command line flag. +-d
command line flag. Conventionally, the files are: --
However, these conventions need not be adhered to. -conf/httpd.conf
-- Contains directives that control the operation of the server daemon. -The filename may be overridden with the
-f
command line flag. ++
+conf/httpd.conf
+- Contains directives that control the operation of the server daemon. +The filename may be overridden with the
-f
command line flag. -conf/srm.conf
-- Contains directives that control the specification of documents that +
conf/srm.conf
+- Contains directives that control the specification of documents that the server can provide to clients. The filename may be overridden with the ResourceConfig directive. -
conf/access.conf
-- Contains directives that control access to documents. +
conf/access.conf
+- Contains directives that control access to documents. The filename may be overridden with the AccessConfig directive. -
+
The server also reads a file containing mime document types; the filename is set by the TypesConfig directive, -and is
conf/mime.types
by default. +and isconf/mime.types
by default.Log files
security warning
@@ -102,25 +102,25 @@ the consequences; see the security tips document for details.pid file
On daemon startup, it saves the process id of the parent httpd process to -the filelogs/httpd.pid
. This filename can be changed with the +the filelogs/httpd.pid
. This filename can be changed with the PidFile directive. The process-id is for use by the administrator in restarting and terminating the daemon; A HUP or USR1 signal causes the daemon to re-read its configuration files and a TERM signal causes it to die gracefully. For more information -see the Stopping and Restarting page. -+see the Stopping and Restarting page. +
If the process dies (or is killed) abnormally, then it will be necessary to kill the children httpd processes.
Error log
-The server will log error messages to a log file,logs/error_log
+The server will log error messages to a log file,logs/error_log
by default. The filename can be set using the ErrorLog directive; different error logs can be set for different virtual hosts.Transfer log
The server will typically log each request to a transfer file, -logs/access_log
by default. The filename can be set using a +logs/access_log
by default. The filename can be set using a TransferLog directive; different transfer logs can be set for different virtual hosts. diff --git a/docs/manual/location.html b/docs/manual/location.html index 96ab3a8544..b5c3fd5e30 100644 --- a/docs/manual/location.html +++ b/docs/manual/location.html @@ -15,43 +15,43 @@Access Control by URL
-The
+<Location>
DirectiveThe
-Syntax: <Location URL prefix><Location>
Directive
-Context: server config, virtual host
-Status: core
+Syntax: <Location URL prefix>
+Context: server config, virtual host
+Status: core
-The <Location> directive provides for access control by -URL. It is comparable to the <Directory> directive, and +
The <Location> directive provides for access control by +URL. It is comparable to the <Directory> directive, and should be matched with a </Location> directive. Directives that apply to the URL given should be listen -within.
+<Directory> sections and<Location>
sections are processed in the +within.<Location>
sections are processed in the order they appear in the configuration file, after the -<Directory> sections and.htaccess
files are -read..htaccess
files are +read. -Note that, due to the way HTTP functions, URL prefix -should, save for proxy requests, be of the form
/path/
, -and should not include thehttp://servername
. It doesn't +Note that, due to the way HTTP functions, URL prefix +should, save for proxy requests, be of the form
/path/
, +and should not include thehttp://servername
. It doesn't necessarily have to protect a directory (it can be an individual file, or a number of files), and can include wild-cards. In a wild-card string, `?' matches any single character, and `*' matches any sequences of characters. -This functionality is especially useful when combined with the -
SetHandler
+This functionality is especially useful when combined with the +
SetHandler
directive. For example, to enable status requests, but allow them only from browsers at foo.com, you might use: -+diff --git a/docs/manual/misc/API.html b/docs/manual/misc/API.html index dba84c18d5..fdcd8737a3 100644 --- a/docs/manual/misc/API.html +++ b/docs/manual/misc/API.html @@ -1,7 +1,7 @@ - -<Location /status> SetHandler server-status order deny,allow deny from all allow from .foo.com </Location> -+Apache API notes - + +Apache API notes + -Apache API notes
+Apache API notes
These are some notes on the Apache API and the data structures you have to deal with, etc. They are not yet nearly complete, but hopefully, they will help you get your bearings. Keep in mind that the API is still subject to change as we gain experience with it. -(See the TODO file for what might be coming). However, +(See the TODO file for what might be coming). However, it will be easy to adapt modules to any changes that are made. (We have more modules to adapt than you do). -+
A few notes on general pedagogical style here. In the interest of conciseness, all structure declarations here are incomplete --- the @@ -28,77 +28,77 @@ real ones have more slots that I'm not telling you about. For the most part, these are reserved to one component of the server core or another, and should be altered by modules with caution. However, in some cases, they really are things I just haven't gotten around to -yet. Welcome to the bleeding edge.
+yet. Welcome to the bleeding edge.
Finally, here's an outline, to give you some bare idea of what's coming up, and in what order: -
-
- -- Basic concepts. - -
- How handlers work - -
- Resource allocation and resource pools -
- Configuration, commands and the like - -
Basic concepts.
++
+ +- Basic concepts. + +
- How handlers work + +
- Resource allocation and resource pools +
- Configuration, commands and the like + +
Basic concepts.
We begin with an overview of the basic concepts behind the API, and how they are manifested in the code. -Handlers, Modules, and Requests
+Handlers, Modules, and Requests
Apache breaks down request handling into a series of steps, more or less the same way the Netscape server API does (although this API has a few more stages than NetSite does, as hooks for stuff I thought might be useful in the future). These are: --
These phases are handled by looking at each of a succession of -modules, looking to see if each of them has a handler for the +modules, looking to see if each of them has a handler for the phase, and attempting invoking it if so. The handler can typically do one of three things: -- URI -> Filename translation -
- Auth ID checking [is the user who they say they are?] -
- Auth access checking [is the user authorized here?] -
- Access checking other than auth -
- Determining MIME type of the object requested -
- `Fixups' --- there aren't any of these yet, but the phase is +
+
+- URI -> Filename translation +
- Auth ID checking [is the user who they say they are?] +
- Auth access checking [is the user authorized here?] +
- Access checking other than auth +
- Determining MIME type of the object requested +
- `Fixups' --- there aren't any of these yet, but the phase is intended as a hook for possible extensions like -
SetEnv
, which don't really fit well elsewhere. -- Actually sending a response back to the client. -
- Logging the request -
SetEnv
, which don't really fit well elsewhere. +- Actually sending a response back to the client. +
- Logging the request +
-
Most phases are terminated by the first module that handles them; however, for logging, `fixups', and non-access authentication @@ -106,62 +106,62 @@ checking, all handlers always run (barring an error). Also, the response phase is unique in that modules may declare multiple handlers for it, via a dispatch table keyed on the MIME type of the requested object. Modules may declare a response-phase handler which can handle -any request, by giving it the key- Handle the request, and indicate that it has done so - by returning the magic constant
OK
. -- Decline to handle the request, by returning the magic - integer constant
DECLINED
. In this case, the ++
+- Handle the request, and indicate that it has done so + by returning the magic constant
OK
. +- Decline to handle the request, by returning the magic + integer constant
DECLINED
. In this case, the server behaves in all respects as if the handler simply hadn't been there. -- Signal an error, by returning one of the HTTP error codes. +
- Signal an error, by returning one of the HTTP error codes. This terminates normal handling of the request, although an ErrorDocument may be invoked to try to mop up, and it will be logged in any case. -
*/*
(i.e., a +any request, by giving it the key*/*
(i.e., a wildcard MIME type specification). However, wildcard handlers are only invoked if the server has already tried and failed to find a more specific response handler for the MIME type of the requested object -(either none existed, or they all declined).+(either none existed, or they all declined).
The handlers themselves are functions of one argument (a -
request_rec
structure. vide infra), which returns an -integer, as above.+
request_rec
structure. vide infra), which returns an +integer, as above.-
A brief tour of a module
+A brief tour of a module
At this point, we need to explain the structure of a module. Our candidate will be one of the messier ones, the CGI module --- this -handles both CGI scripts and theScriptAlias
config file +handles both CGI scripts and theScriptAlias
config file command. It's actually a great deal more complicated than most modules, but if we're going to have only one example, it might as well -be the one with its fingers in every place.+be the one with its fingers in every place.
Let's begin with handlers. In order to handle the CGI scripts, the module declares a response handler for them. Because of -
ScriptAlias
, it also has handlers for the name -translation phase (to recognizeScriptAlias
ed URIs), the -type-checking phase (anyScriptAlias
ed request is typed -as a CGI script).+
ScriptAlias
, it also has handlers for the name +translation phase (to recognizeScriptAlias
ed URIs), the +type-checking phase (anyScriptAlias
ed request is typed +as a CGI script).The module needs to maintain some per (virtual) -server information, namely, the
ScriptAlias
es in effect; +server information, namely, theScriptAlias
es in effect; the module structure therefore contains pointers to a functions which builds these structures, and to another which combines two of them (in case the main server and a virtual server both have -ScriptAlias
es declared).+
ScriptAlias
es declared).Finally, this module contains code to handle the -
ScriptAlias
command itself. This particular module only +ScriptAlias
command itself. This particular module only declares one command, but there could be more, so modules have -command tables which declare their commands, and describe -where they are permitted, and how they are to be invoked.+command tables which declare their commands, and describe +where they are permitted, and how they are to be invoked.
A final note on the declared types of the arguments of some of these -commands: a
pool
is a pointer to a resource pool +commands: apool
is a pointer to a resource pool structure; these are used by the server to keep track of the memory which has been allocated, files opened, etc., either to service a particular request, or to handle the process of configuring itself. That way, when the request is over (or, for the configuration pool, when the server is restarting), the memory can be freed, and the files -closed, en masse, without anyone having to write explicit code to +closed, en masse, without anyone having to write explicit code to track them all down and dispose of them. Also, a -cmd_parms
structure contains various information about +cmd_parms
structure contains various information about the config file being read, and other status information, which is sometimes of use to the function which processes a config-file command -(such asScriptAlias
). +(such asScriptAlias
). With no further ado, the module itself: -+-/* Declarations of handlers. */ int translate_scriptalias (request_rec *); @@ -213,34 +213,34 @@ module cgi_module = { NULL, /* logger */ NULL /* header parser */ }; -+How handlers work
+How handlers work
-The sole argument to handlers is arequest_rec
structure. +The sole argument to handlers is arequest_rec
structure. This structure describes a particular request which has been made to the server, on behalf of a client. In most cases, each connection to -the client generates only onerequest_rec
structure.+the client generates only one
request_rec
structure.-
A brief tour of the
+request_rec
A brief tour of the
-Therequest_rec
request_rec
contains pointers to a resource pool +Therequest_rec
contains pointers to a resource pool which will be cleared when the server is finished handling the request; to structures containing per-server and per-connection -information, and most importantly, information on the request itself.+information, and most importantly, information on the request itself.
The most important such information is a small set of character strings describing attributes of the object being requested, including its URI, filename, content-type and content-encoding (these being filled in by the translation and type-check handlers which handle the -request, respectively).
+request, respectively).
Other commonly used data items are tables giving the MIME headers on the client's original request, MIME headers to be sent back with the response (which modules can add to at will), and environment variables for any subprocesses which are spawned off in the course of servicing the request. These tables are manipulated using the -
table_get
andtable_set
routines.+
table_get
andtable_set
routines.
Note that the Content-type header value cannot be set by module content-handlers using the table_*() @@ -255,17 +255,17 @@ Finally, there are pointers to two data structures which, in turn, point to per-module configuration structures. Specifically, these hold pointers to the data structures which the module has built to describe the way it has been configured to operate in a given -directory (via.htaccess
files or -<Directory>
sections), for private data it has +directory (via.htaccess
files or +<Directory>
sections), for private data it has built in the course of servicing the request (so modules' handlers for one phase can pass `notes' to their handlers for other phases). There -is another such configuration vector in theserver_rec
-data structure pointed to by therequest_rec
, which -contains per (virtual) server configuration data.+is another such configuration vector in the
server_rec
+data structure pointed to by therequest_rec
, which +contains per (virtual) server configuration data.-Here is an abridged declaration, giving the fields most commonly used:
+Here is an abridged declaration, giving the fields most commonly used:
-
+-struct request_rec { pool *pool; @@ -327,101 +327,101 @@ struct request_rec { }; -+Where request_rec structures come from
+Where request_rec structures come from
-Mostrequest_rec
structures are built by reading an HTTP +Mostrequest_rec
structures are built by reading an HTTP request from a client, and filling in the fields. However, there are a few exceptions: --
-- If the request is to an imagemap, a type map (i.e., a -
*.var
file), or a CGI script which returned a ++
+ function- If the request is to an imagemap, a type map (i.e., a +
*.var
file), or a CGI script which returned a local `Location:', then the resource which the user requested is going to be ultimately located by some URI other than what the client originally supplied. In this case, the server does - an internal redirect, constructing a new -request_rec
for the new URI, and processing it + an internal redirect, constructing a new +request_rec
for the new URI, and processing it almost exactly as if the client had requested the new URI - directly.+ directly.
-
- If some handler signaled an error, and an -
ErrorDocument
is in scope, the same internal - redirect machinery comes into play.+
- If some handler signaled an error, and an +
ErrorDocument
is in scope, the same internal + redirect machinery comes into play.-
- Finally, a handler occasionally needs to investigate `what +
- Finally, a handler occasionally needs to investigate `what would happen if' some other request were run. For instance, the directory indexing module needs to know what MIME type would be assigned to a request for each directory entry, in - order to figure out what icon to use.
+ order to figure out what icon to use.
- Such handlers can construct a sub-request, using the - functions
sub_req_lookup_file
and -sub_req_lookup_uri
; this constructs a new -request_rec
structure and processes it as you + Such handlers can construct a sub-request, using the + functionssub_req_lookup_file
and +sub_req_lookup_uri
; this constructs a new +request_rec
structure and processes it as you would expect, up to but not including the point of actually sending a response. (These functions skip over the access checks if the sub-request is for a file in the same directory - as the original request).+ as the original request).
(Server-side includes work by building sub-requests and then actually invoking the response handler for them, via the - function
run_sub_request
). -run_sub_request
). +Handling requests, declining, and returning error codes
+Handling requests, declining, and returning error codes
As discussed above, each handler, when invoked to handle a particular -request_rec
, has to return anint
to +request_rec
, has to return anint
to indicate what happened. That can either be --
-Note that if the error code returned is- OK --- the request was handled successfully. This may or may +
+
+- OK --- the request was handled successfully. This may or may not terminate the phase. -
- DECLINED --- no erroneous condition exists, but the module +
- DECLINED --- no erroneous condition exists, but the module declines to handle the phase; the server tries to find another. -
- an HTTP error code, which aborts handling of the request. -
- an HTTP error code, which aborts handling of the request. +
REDIRECT
, then -the module should put aLocation
in the request's -headers_out
, to indicate where the client should be -redirected to.+Note that if the error code returned is
REDIRECT
, then +the module should put aLocation
in the request's +headers_out
, to indicate where the client should be +redirected to.-
Special considerations for response handlers
+Special considerations for response handlers
Handlers for most phases do their work by simply setting a few fields -in therequest_rec
structure (or, in the case of access +in therequest_rec
structure (or, in the case of access checkers, simply by returning the correct error code). However, -response handlers have to actually send a request back to the client.+response handlers have to actually send a request back to the client.
They should begin by sending an HTTP response header, using the -function
send_http_header
. (You don't have to do +functionsend_http_header
. (You don't have to do anything special to skip sending the header for HTTP/0.9 requests; the function figures out on its own that it shouldn't do anything). If -the request is markedheader_only
, that's all they should +the request is markedheader_only
, that's all they should do; they should return after that, without attempting any further -output.+output.
Otherwise, they should produce a request body which responds to the -client as appropriate. The primitives for this are
rputc
-andrprintf
, for internally generated output, and -send_fd
, to copy the contents of someFILE *
-straight to the client.+client as appropriate. The primitives for this are
rputc
+andrprintf
, for internally generated output, and +send_fd
, to copy the contents of someFILE *
+straight to the client.At this point, you should more or less understand the following piece -of code, which is the handler which handles
GET
requests +of code, which is the handler which handlesGET
requests which have no more specific handler; it also shows how conditional -GET
s can be handled, if it's desirable to do so in a -particular response handler ---set_last_modified
checks -against theIf-modified-since
value supplied by the +GET
s can be handled, if it's desirable to do so in a +particular response handler ---set_last_modified
checks +against theIf-modified-since
value supplied by the client, if any, and returns an appropriate code (which will, if nonzero, be USE_LOCAL_COPY). No similar considerations apply for -set_content_length
, but it returns an error code for -symmetry.+
set_content_length
, but it returns an error code for +symmetry.-
+Finally, if all of this is too much of a challenge, there are a few ways out of it. First off, as shown above, a response handler which has not yet produced any output can simply return an error code, in which case the server will automatically produce an error response. Secondly, it can punt to some other handler by invoking -int default_handler (request_rec *r) { int errstatus; @@ -449,96 +449,96 @@ int default_handler (request_rec *r) pfclose (r->pool, f); return OK; } -+internal_redirect
, which is how the internal redirection +internal_redirect
, which is how the internal redirection machinery discussed above is invoked. A response handler which has -internally redirected should always returnOK
.+internally redirected should always return
OK
.-(Invoking
internal_redirect
from handlers which are -not response handlers will lead to serious confusion). +(Invokinginternal_redirect
from handlers which are +not response handlers will lead to serious confusion). -Special considerations for authentication handlers
+Special considerations for authentication handlers
Stuff that should be discussed here in detail: --
-- Authentication-phase handlers not invoked unless auth is +
+
+- Authentication-phase handlers not invoked unless auth is configured for the directory. -
- Common auth configuration stored in the core per-dir - configuration; it has accessors
auth_type
, -auth_name
, andrequires
. -- Common routines, to handle the protocol end of things, at least - for HTTP basic authentication (
get_basic_auth_pw
, - which sets theconnection->user
structure field - automatically, andnote_basic_auth_failure
, which - arranges for the properWWW-Authenticate:
header +- Common auth configuration stored in the core per-dir + configuration; it has accessors
auth_type
, +auth_name
, andrequires
. +- Common routines, to handle the protocol end of things, at least + for HTTP basic authentication (
get_basic_auth_pw
, + which sets theconnection->user
structure field + automatically, andnote_basic_auth_failure
, which + arranges for the properWWW-Authenticate:
header to be sent back). -Special considerations for logging handlers
+Special considerations for logging handlers
When a request has internally redirected, there is the question of what to log. Apache handles this by bundling the entire chain of -redirects into a list ofrequest_rec
structures which are -threaded through ther->prev
andr->next
-pointers. Therequest_rec
which is passed to the logging +redirects into a list ofrequest_rec
structures which are +threaded through ther->prev
andr->next
+pointers. Therequest_rec
which is passed to the logging handlers in such cases is the one which was originally built for the initial request from the client; note that the bytes_sent field will only be correct in the last request in the chain (the one for which a response was actually sent). -Resource allocation and resource pools
+Resource allocation and resource pools
One of the problems of writing and designing a server-pool server is that of preventing leakage, that is, allocating resources (memory, open files, etc.), without subsequently releasing them. The resource pool machinery is designed to make it easy to prevent this from happening, by allowing resource to be allocated in such a way that -they are automatically released when the server is done with -them.+they are automatically released when the server is done with +them.
The way this works is as follows: the memory which is allocated, file opened, etc., to deal with a particular request are tied to a -resource pool which is allocated for the request. The pool -is a data structure which itself tracks the resources in question.
+resource pool which is allocated for the request. The pool +is a data structure which itself tracks the resources in question.
-When the request has been processed, the pool is cleared. At +When the request has been processed, the pool is cleared. At that point, all the memory associated with it is released for reuse, all files associated with it are closed, and any other clean-up functions which are associated with the pool are run. When this is over, we can be confident that all the resource tied to the pool have -been released, and that none of them have leaked.
+been released, and that none of them have leaked.
Server restarts, and allocation of memory and resources for per-server configuration, are handled in a similar way. There is a -configuration pool, which keeps track of resources which were +configuration pool, which keeps track of resources which were allocated while reading the server configuration files, and handling the commands therein (for instance, the memory that was allocated for per-server module configuration, log files and other files that were opened, and so forth). When the server restarts, and has to reread the configuration files, the configuration pool is cleared, and so the memory and file descriptors which were taken up by reading them the -last time are made available for reuse.
+last time are made available for reuse.
It should be noted that use of the pool machinery isn't generally obligatory, except for situations like logging handlers, where you really need to register cleanups to make sure that the log file gets closed when the server restarts (this is most easily done by using the -function
pfopen
, which also +functionpfopen
, which also arranges for the underlying file descriptor to be closed before any -child processes, such as for CGI scripts, areexec
ed), or +child processes, such as for CGI scripts, areexec
ed), or in case you are using the timeout machinery (which isn't yet even documented here). However, there are two benefits to using it: resources allocated to a pool never leak (even if you allocate a scratch string, and just forget about it); also, for memory -allocation,palloc
is generally faster than -malloc
.+allocation,
palloc
is generally faster than +malloc
.We begin here by describing how memory is allocated to pools, and then discuss how other resources are tracked by the resource pool @@ -547,15 +547,15 @@ machinery.
Allocation of memory in pools
Memory is allocated to pools by calling the function -palloc
, which takes two arguments, one being a pointer to +palloc
, which takes two arguments, one being a pointer to a resource pool structure, and the other being the amount of memory to -allocate (inchar
s). Within handlers for handling +allocate (inchar
s). Within handlers for handling requests, the most common way of getting a resource pool structure is -by looking at thepool
slot of the relevant -request_rec
; hence the repeated appearance of the +by looking at thepool
slot of the relevant +request_rec
; hence the repeated appearance of the following idiom in module code: -+-Note that there is noint my_handler(request_rec *r) { struct my_structure *foo; @@ -563,20 +563,20 @@ int my_handler(request_rec *r) foo = (foo *)palloc (r->pool, sizeof(my_structure)); } -+pfree
--- -palloc
ed memory is freed only when the associated -resource pool is cleared. This means thatpalloc
does not -have to do as much accounting asmalloc()
; all it does in +Note that there is nopfree
--- +palloc
ed memory is freed only when the associated +resource pool is cleared. This means thatpalloc
does not +have to do as much accounting asmalloc()
; all it does in the typical case is to round up the size, bump a pointer, and do a -range check.+range check.
-(It also raises the possibility that heavy use of
palloc
+(It also raises the possibility that heavy use ofpalloc
could cause a server process to grow excessively large. There are two ways to deal with this, which are dealt with below; briefly, you -can usemalloc
, and try to be sure that all of the memory -gets explicitlyfree
d, or you can allocate a sub-pool of +can usemalloc
, and try to be sure that all of the memory +gets explicitlyfree
d, or you can allocate a sub-pool of the main pool, allocate your memory in the sub-pool, and clear it out periodically. The latter technique is discussed in the section on sub-pools below, and is used in the directory-indexing code, in order @@ -586,107 +586,107 @@ thousands of files).Allocating initialized memory
There are functions which allocate initialized memory, and are -frequently useful. The functionpcalloc
has the same -interface aspalloc
, but clears out the memory it -allocates before it returns it. The functionpstrdup
-takes a resource pool and achar *
as arguments, and +frequently useful. The functionpcalloc
has the same +interface aspalloc
, but clears out the memory it +allocates before it returns it. The functionpstrdup
+takes a resource pool and achar *
as arguments, and allocates memory for a copy of the string the pointer points to, -returning a pointer to the copy. Finallypstrcat
is a +returning a pointer to the copy. Finallypstrcat
is a varargs-style function, which takes a pointer to a resource pool, and -at least twochar *
arguments, the last of which must be -NULL
. It allocates enough memory to fit copies of each +at least twochar *
arguments, the last of which must be +NULL
. It allocates enough memory to fit copies of each of the strings, as a unit; for instance: -+returns a pointer to 8 bytes worth of memory, initialized to -pstrcat (r->pool, "foo", "/", "bar", NULL); -+"foo/bar"
. +"foo/bar"
. -Tracking open files, etc.
+Tracking open files, etc.
As indicated above, resource pools are also used to track other sorts of resources besides memory. The most common are open files. The -routine which is typically used for this ispfopen
, which +routine which is typically used for this ispfopen
, which takes a resource pool and two strings as arguments; the strings are -the same as the typical arguments tofopen
, e.g., +the same as the typical arguments tofopen
, e.g., -+-There is also a... FILE *f = pfopen (r->pool, r->filename, "r"); if (f == NULL) { ... } else { ... } -+popenf
routine, which parallels the -lower-levelopen
system call. Both of these routines +There is also apopenf
routine, which parallels the +lower-levelopen
system call. Both of these routines arrange for the file to be closed when the resource pool in question -is cleared.+is cleared.
-Unlike the case for memory, there are functions to close -files allocated with
pfopen
, andpopenf
, -namelypfclose
andpclosef
. (This is +Unlike the case for memory, there are functions to close +files allocated withpfopen
, andpopenf
, +namelypfclose
andpclosef
. (This is because, on many systems, the number of files which a single process can have open is quite limited). It is important to use these -functions to close files allocated withpfopen
and -popenf
, since to do otherwise could cause fatal errors on +functions to close files allocated withpfopen
and +popenf
, since to do otherwise could cause fatal errors on systems such as Linux, which react badly if the same -FILE*
is closed more than once.+
FILE*
is closed more than once.-(Using the
close
functions is not mandatory, since the +(Using theclose
functions is not mandatory, since the file will eventually be closed regardless, but you should consider it in cases where your module is opening, or could open, a lot of files).Other sorts of resources --- cleanup functions
More text goes here. Describe the the cleanup primitives in terms of -which the file stuff is implemented; also,spawn_process
. +which the file stuff is implemented; also,spawn_process
.Fine control --- creating and dealing with sub-pools, with a note on sub-requests
-On rare occasions, too-free use ofpalloc()
and the +On rare occasions, too-free use ofpalloc()
and the associated primitives may result in undesirably profligate resource allocation. You can deal with such a case by creating a -sub-pool, allocating within the sub-pool rather than the main +sub-pool, allocating within the sub-pool rather than the main pool, and clearing or destroying the sub-pool, which releases the -resources which were associated with it. (This really is a +resources which were associated with it. (This really is a rare situation; the only case in which it comes up in the standard module set is in case of listing directories, and then only with -very large directories. Unnecessary use of the primitives +very large directories. Unnecessary use of the primitives discussed here can hair up your code quite a bit, with very little -gain).+gain).
-The primitive for creating a sub-pool is
make_sub_pool
, +The primitive for creating a sub-pool ismake_sub_pool
, which takes another pool (the parent pool) as an argument. When the main pool is cleared, the sub-pool will be destroyed. The sub-pool may also be cleared or destroyed at any time, by calling the functions -clear_pool
anddestroy_pool
, respectively. -(The difference is thatclear_pool
frees resources -associated with the pool, whiledestroy_pool
also +clear_pool
anddestroy_pool
, respectively. +(The difference is thatclear_pool
frees resources +associated with the pool, whiledestroy_pool
also deallocates the pool itself. In the former case, you can allocate new resources within the pool, and clear it again, and so forth; in the -latter case, it is simply gone).+latter case, it is simply gone).
One final note --- sub-requests have their own resource pools, which are sub-pools of the resource pool for the main request. The polite way to reclaim the resources associated with a sub request which you -have allocated (using the
sub_req_lookup_...
functions) -isdestroy_sub_request
, which frees the resource pool. +have allocated (using thesub_req_lookup_...
functions) +isdestroy_sub_request
, which frees the resource pool. Before calling this function, be sure to copy anything that you care about which might be allocated in the sub-request's resource pool into someplace a little less volatile (for instance, the filename in its -request_rec
structure).+
request_rec
structure).(Again, under most circumstances, you shouldn't feel obliged to call this function; only 2K of memory or so are allocated for a typical sub request, and it will be freed anyway when the main request pool is cleared. It is only when you are allocating many, many sub-requests for a single main request that you should seriously consider the -
destroy...
functions). +destroy...
functions). -Configuration, commands and the like
+Configuration, commands and the like
One of the design goals for this server was to maintain external compatibility with the NCSA 1.3 server --- that is, to read the same @@ -696,7 +696,7 @@ hand, another design goal was to move as much of the server's functionality into modules which have as little as possible to do with the monolithic server core. The only way to reconcile these goals is to move the handling of most commands from the central server into the -modules.+modules.
However, just giving the modules command tables is not enough to divorce them completely from the server core. The server has to @@ -705,77 +705,77 @@ maintaining data which is private to the modules, and which can be either per-server, or per-directory. Most things are per-directory, including in particular access control and authorization information, but also information on how to determine file types from suffixes, -which can be modified by
AddType
and -DefaultType
directives, and so forth. In general, the -governing philosophy is that anything which can be made +which can be modified byAddType
and +DefaultType
directives, and so forth. In general, the +governing philosophy is that anything which can be made configurable by directory should be; per-server information is generally used in the standard set of modules for information like -Alias
es andRedirect
s which come into play +Alias
es andRedirect
s which come into play before the request is tied to a particular place in the underlying -file system.+file system.
Another requirement for emulating the NCSA server is being able to handle the per-directory configuration files, generally called -
.htaccess
files, though even in the NCSA server they can +.htaccess
files, though even in the NCSA server they can contain directives which have nothing at all to do with access control. Accordingly, after URI -> filename translation, but before performing any other phase, the server walks down the directory hierarchy of the underlying filesystem, following the translated -pathname, to read any.htaccess
files which might be +pathname, to read any.htaccess
files which might be present. The information which is read in then has to be -merged with the applicable information from the server's own -config files (either from the<Directory>
sections -inaccess.conf
, or from defaults in -srm.conf
, which actually behaves for most purposes almost -exactly like<Directory />
).+merged with the applicable information from the server's own +config files (either from the
<Directory>
sections +inaccess.conf
, or from defaults in +srm.conf
, which actually behaves for most purposes almost +exactly like<Directory />
).Finally, after having served a request which involved reading -
.htaccess
files, we need to discard the storage allocated +.htaccess
files, we need to discard the storage allocated for handling them. That is solved the same way it is solved wherever else similar problems come up, by tying those structures to the -per-transaction resource pool.+per-transaction resource pool.
-
Per-directory configuration structures
+Per-directory configuration structures
-Let's look out how all of this plays out inmod_mime.c
, +Let's look out how all of this plays out inmod_mime.c
, which defines the file typing handler which emulates the NCSA server's behavior of determining file types from suffixes. What we'll be looking at, here, is the code which implements the -AddType
andAddEncoding
commands. These -commands can appear in.htaccess
files, so they must be +AddType
andAddEncoding
commands. These +commands can appear in.htaccess
files, so they must be handled in the module's private per-directory data, which in fact, -consists of two separatetable
s for MIME types and +consists of two separatetable
s for MIME types and encoding information, and is declared as follows: -+When the server is reading a configuration file, or -typedef struct { table *forced_types; /* Additional AddTyped stuff */ table *encoding_types; /* Added with AddEncoding... */ } mime_dir_config; -+<Directory>
section, which includes one of the MIME -module's commands, it needs to create amime_dir_config
+<Directory>
section, which includes one of the MIME +module's commands, it needs to create amime_dir_config
structure, so those commands have something to act on. It does this by invoking the function it finds in the module's `create per-dir config slot', with two arguments: the name of the directory to which -this configuration information applies (orNULL
for -srm.conf
), and a pointer to a resource pool in which the -allocation should happen.+this configuration information applies (or
NULL
for +srm.conf
), and a pointer to a resource pool in which the +allocation should happen.-(If we are reading a
.htaccess
file, that resource pool +(If we are reading a.htaccess
file, that resource pool is the per-request resource pool for the request; otherwise it is a resource pool which is used for configuration data, and cleared on restarts. Either way, it is important for the structure being created to vanish when the pool is cleared, by registering a cleanup on the -pool if necessary).+pool if necessary).
For the MIME module, the per-dir config creation function just -
palloc
s the structure above, and a creates a couple of -table
s to fill it. That looks like this: +palloc
s the structure above, and a creates a couple of +table
s to fill it. That looks like this: -+-Now, suppose we've just read in avoid *create_mime_dir_config (pool *p, char *dummy) { mime_dir_config *new = @@ -786,15 +786,15 @@ void *create_mime_dir_config (pool *p, char *dummy) return new; } -+.htaccess
file. We +Now, suppose we've just read in a.htaccess
file. We already have the per-directory configuration structure for the next -directory up in the hierarchy. If the.htaccess
file we -just read in didn't have anyAddType
or -AddEncoding
commands, its per-directory config structure +directory up in the hierarchy. If the.htaccess
file we +just read in didn't have anyAddType
or +AddEncoding
commands, its per-directory config structure for the MIME module is still valid, and we can just use it. -Otherwise, we need to merge the two structures somehow.+Otherwise, we need to merge the two structures somehow.
To do that, the server invokes the module's per-directory config merge function, if one is present. That function takes three arguments: @@ -803,7 +803,7 @@ allocate the result. For the MIME module, all that needs to be done is overlay the tables from the new per-directory config structure with those from the parent: -
+As a note --- if there is no per-directory merge function present, the server will just use the subdirectory's configuration info, and ignore the parent's. For some modules, that works just fine (e.g., for the includes module, whose per-directory configuration information -consists solely of the state of thevoid *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv) { mime_dir_config *parent_dir = (mime_dir_config *)parent_dirv; @@ -818,63 +818,63 @@ void *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv) return new; } -+XBITHACK
), and for +consists solely of the state of theXBITHACK
), and for those modules, you can just not declare one, and leave the -corresponding structure slot in the module itselfNULL
.+corresponding structure slot in the module itself
NULL
.-
Command handling
+Command handling
Now that we have these structures, we need to be able to figure out how to fill them. That involves processing the actual -AddType
andAddEncoding
commands. To find -commands, the server looks in the module'scommand table
. +AddType
andAddEncoding
commands. To find +commands, the server looks in the module'scommand table
. That table contains information on how many arguments the commands take, and in what formats, where it is permitted, and so forth. That information is sufficient to allow the server to invoke most command-handling functions with pre-parsed arguments. Without further -ado, let's look at theAddType
command handler, which -looks like this (theAddEncoding
command looks basically +ado, let's look at theAddType
command handler, which +looks like this (theAddEncoding
command looks basically the same, and won't be shown here): -+This command handler is unusually simple. As you can see, it takes four arguments, two of which are pre-parsed arguments, the third being the per-directory configuration structure for the module in question, -and the fourth being a pointer to achar *add_type(cmd_parms *cmd, mime_dir_config *m, char *ct, char *ext) { if (*ext == '.') ++ext; table_set (m->forced_types, ext, ct); return NULL; } -+cmd_parms
structure. +and the fourth being a pointer to acmd_parms
structure. That structure contains a bunch of arguments which are frequently of use to some, but not all, commands, including a resource pool (from which memory can be allocated, and to which cleanups should be tied), and the (virtual) server being configured, from which the module's -per-server configuration data can be obtained if required.+per-server configuration data can be obtained if required.
Another way in which this particular command handler is unusually simple is that there are no error conditions which it can encounter. If there were, it could return an error message instead of -
NULL
; this causes an error to be printed out on the -server'sstderr
, followed by a quick exit, if it is in -the main config files; for a.htaccess
file, the syntax +NULL
; this causes an error to be printed out on the +server'sstderr
, followed by a quick exit, if it is in +the main config files; for a.htaccess
file, the syntax error is logged in the server error log (along with an indication of where it came from), and the request is bounced with a server error -response (HTTP error status, code 500).+response (HTTP error status, code 500).
The MIME module's command table has entries for these commands, which look like this: -
+The entries in these tables are: -command_rec mime_cmds[] = { { "AddType", add_type, NULL, OR_FILEINFO, TAKE2, "a mime type followed by a file extension" }, @@ -882,54 +882,54 @@ command_rec mime_cmds[] = { "an encoding (e.g., gzip), followed by a file extension" }, { NULL } }; -+-
Finally, having set this all up, we have to use it. This is ultimately done in the module's handlers, specifically for its file-typing handler, which looks more or less like this; note that the per-directory configuration structure is extracted from the -- The name of the command -
- The function which handles it -
- a
(void *)
pointer, which is passed in the -cmd_parms
structure to the command handler --- ++
+- The name of the command +
- The function which handles it +
- a
(void *)
pointer, which is passed in the +cmd_parms
structure to the command handler --- this is useful in case many similar commands are handled by the same function. -- A bit mask indicating where the command may appear. There are - mask bits corresponding to each
AllowOverride
- option, and an additional mask bit,RSRC_CONF
, +- A bit mask indicating where the command may appear. There are + mask bits corresponding to each
AllowOverride
+ option, and an additional mask bit,RSRC_CONF
, indicating that the command may appear in the server's own - config files, but not in any.htaccess
+ config files, but not in any.htaccess
file. -- A flag indicating how many arguments the command handler wants +
- A flag indicating how many arguments the command handler wants pre-parsed, and how they should be passed in. -
TAKE2
indicates two pre-parsed arguments. Other - options areTAKE1
, which indicates one pre-parsed - argument,FLAG
, which indicates that the argument - should beOn
orOff
, and is passed in - as a boolean flag,RAW_ARGS
, which causes the +TAKE2
indicates two pre-parsed arguments. Other + options areTAKE1
, which indicates one pre-parsed + argument,FLAG
, which indicates that the argument + should beOn
orOff
, and is passed in + as a boolean flag,RAW_ARGS
, which causes the server to give the command the raw, unparsed arguments (everything but the command name itself). There is also -ITERATE
, which means that the handler looks the - same asTAKE1
, but that if multiple arguments are +ITERATE
, which means that the handler looks the + same asTAKE1
, but that if multiple arguments are present, it should be called multiple times, and finally -ITERATE2
, which indicates that the command handler - looks like aTAKE2
, but if more arguments are +ITERATE2
, which indicates that the command handler + looks like aTAKE2
, but if more arguments are present, then it should be called multiple times, holding the first argument constant. -- Finally, we have a string which describes the arguments that +
- Finally, we have a string which describes the arguments that should be present. If the arguments in the actual config file are not as required, this string will be used to help give a more specific error message. (You can safely leave this -
NULL
). -NULL
). +request_rec
's per-directory configuration vector by using -theget_module_config
function. +request_rec
's per-directory configuration vector by using +theget_module_config
function. -+-int find_ct(request_rec *r) { int i; @@ -965,9 +965,9 @@ int find_ct(request_rec *r) return OK; } -+Side notes --- per-server configuration, virtual servers, etc.
+Side notes --- per-server configuration, virtual servers, etc.
The basic ideas behind per-server module configuration are basically the same as those for per-directory configuration; there is a creation @@ -976,17 +976,17 @@ virtual server has partially overridden the base server configuration, and a combined structure must be computed. (As with per-directory configuration, the default if no merge function is specified, and a module is configured in some virtual server, is that the base -configuration is simply ignored).+configuration is simply ignored).
The only substantial difference is that when a command needs to configure the per-server private module data, it needs to go to the -
cmd_parms
data to get at it. Here's an example, from the +cmd_parms
data to get at it. Here's an example, from the alias module, which also indicates how a syntax error can be returned (note that the per-directory configuration argument to the command handler is declared as a dummy, since the module doesn't actually have per-directory config data): -+- + diff --git a/docs/manual/misc/FAQ.html b/docs/manual/misc/FAQ.html index 95bd6c1966..f5284247a3 100644 --- a/docs/manual/misc/FAQ.html +++ b/docs/manual/misc/FAQ.html @@ -15,7 +15,7 @@char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url) { server_rec *s = cmd->server; @@ -999,6 +999,6 @@ char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url) new->fake = f; new->real = url; return NULL; } -+Apache Server Frequently Asked Questions
- $Revision: 1.103 $ ($Date: 1998/01/26 07:09:13 $) + $Revision: 1.104 $ ($Date: 1998/01/26 16:53:48 $)
The latest version of this FAQ is always available from the main @@ -1957,7 +1957,7 @@
Hmmm... there are a lot of reasons. First, mod_rewrite itself is a powerful - module which can help you in really all aspects of URL rewriting, so + module which can help you in really all aspects of URL rewriting, so it can be no trivial module per definition. To accomplish its hard job it uses software leverage and makes use of a powerful regular expression library by Henry Spencer which is an integral part of Apache since its @@ -1967,7 +1967,7 @@
On the other hand mod_rewrite has to work inside the Apache API environment and needs to do some tricks to fit there. For instance the Apache API as of - 1.x really was not designed for URL rewriting at the .htaccess + 1.x really was not designed for URL rewriting at the .htaccess level of processing. Or the problem of multiple rewrites in sequence, which is also not handled by the API per design. To provide this features mod_rewrite has to do some special (but API compliant!) handling which leads diff --git a/docs/manual/misc/client_block_api.html b/docs/manual/misc/client_block_api.html index ea7896b46a..4f65341af6 100644 --- a/docs/manual/misc/client_block_api.html +++ b/docs/manual/misc/client_block_api.html @@ -13,73 +13,73 @@ ALINK="#FF0000" > -
Reading Client Input in Apache 1.2
+Reading Client Input in Apache 1.2
-
+
-Apache 1.1 and earlier let modules handle POST and PUT requests by +
Apache 1.1 and earlier let modules handle POST and PUT requests by themselves. The module would, on its own, determine whether the request had an entity, how many bytes it was, and then called a -function (
read_client_block
) to get the data. +function (read_client_block
) to get the data. -However, HTTP/1.1 requires several things of POST and PUT request +
However, HTTP/1.1 requires several things of POST and PUT request handlers that did not fit into this module, and all existing modules have to be rewritten. The API calls for handling this have been further abstracted, so that future HTTP protocol changes can be -accomplished while remaining backwards-compatible.
+accomplished while remaining backwards-compatible. -
+
The New API Functions
-+-int setup_client_block (request_rec *, int read_policy); int should_client_block (request_rec *); long get_client_block (request_rec *, char *buffer, int buffer_size); -+-
-- Call
setup_client_block()
near the beginning of the request ++
+- Call
setup_client_block()
near the beginning of the request handler. This will set up all the necessary properties, and will return either OK, or an error code. If the latter, the module should return that error code. The second parameter selects the policy to apply if the request message indicates a body, and how a chunked transfer-coding should be interpreted. Choose one of -+In order to use the last two options, the caller MUST provide a buffer large enough to hold a chunk-size line, including any extensions. -REQUEST_NO_BODY Send 413 error if message has any body REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. REQUEST_CHUNKED_PASS Pass the chunks to me without removal. -+- When you are ready to possibly accept input, call -
should_client_block()
. +- When you are ready to possibly accept input, call +
should_client_block()
. This will tell the module whether or not to read input. If it is 0, the module should assume that the input is of a non-entity type (e.g. a GET request). A nonzero response indicates that the module should proceed (to step 3). This step also sends a 100 Continue response to HTTP/1.1 clients, so should not be called until the module - is *definitely* ready to read content. (otherwise, the point of the + is *definitely* ready to read content. (otherwise, the point of the 100 response is defeated). Never call this function more than once. -- Finally, call
get_client_block
in a loop. Pass it a +- Finally, call
get_client_block
in a loop. Pass it a buffer and its size. It will put data into the buffer (not necessarily the full buffer, in the case of chunked inputs), and return the length of the input block. When it is done reading, it will return 0 if EOF, or -1 if there was an error. -As an example, please look at the code in -
+mod_cgi.c
. This is properly written to the new API -guidelines.As an example, please look at the code in +
diff --git a/docs/manual/misc/compat_notes.html b/docs/manual/misc/compat_notes.html index 64abbbe18b..213fc302f4 100644 --- a/docs/manual/misc/compat_notes.html +++ b/docs/manual/misc/compat_notes.html @@ -21,8 +21,8 @@ a couple gotcha's to watch out for. These are mostly due to the fact that the parser for config and access control files was rewritten from scratch, so certain liberties the earlier servers took may not be available here. These are all easily fixable. If you know of other -non-fatal problems that belong here, let us know. +non-fatal problems that belong here, let us know.mod_cgi.c
. This is properly written to the new API +guidelines.Please also check the known bugs page, and the known client @@ -34,13 +34,13 @@ problems page.
- The basic mod_auth
AuthGroupFile
-specified group file format allows commas between user names - Apache does not.
- - added 12/1/96 + - added 12/1/96If you follow the NCSA guidelines for setting up access restrictions based on client domain, you may well have added entries for,
AuthType, AuthName, AuthUserFile
orAuthGroupFile
. - None of these are needed (or appropriate) for restricting access + None of these are needed (or appropriate) for restricting access based on client domain.When Apache sees
AuthType
it (reasonably) assumes you @@ -63,7 +63,7 @@ problems page.-
exec cgi=""
produces reasonable malformed header +exec cgi=""
produces reasonable malformed header responses when used to invoke non-CGI scripts.
The NCSA code ignores the missing header. (bad idea)
Solution: write CGI to the CGI spec or useexec cmd=""
instead. @@ -83,8 +83,8 @@ problems page.- Icons for FancyIndexing broken - well, no, they're not broken, we've just upgraded the icons from flat .xbm files to pretty and much smaller .gif files, courtesy of -Kevin Hughes at -EIT. +Kevin Hughes at +EIT. If you are using the same srm.conf from an old distribution, make sure you add the new page. valid group name (i.e., "nogroup") not the numeric group ID. The distribution httpd.conf, and earlier ones, had the default Group be "#-1", which - was causing silent exits at startup.
+ was causing silent exits at startup.
-
.asis
files: Apache 0.6.5 did not require a Status header; +.asis
files: Apache 0.6.5 did not require a Status header; it added one automatically if the .asis file contained a Location header. -0.8.14 requires a Status header.+0.8.14 requires a Status header.
- Apache versions before 1.2b1 will ignore the last line of configuration @@ -123,16 +123,16 @@ it added one automatically if the .asis file contained a Location header.
- Apache's
<VirtualHost>
treats all addresses as "optional" (i.e. the server should continue booting if it can't resolve the address). Whereas in NCSA the default is to fail booting unless - an addedoptional
keyword is included. + an addedoptional
keyword is included.- Apache does not implement
OnDeny
use -ErrorDocument
+ErrorDocument
instead.- Apache (as of 1.3) always performs the equivalent of -
HostnameLookups minimal
.minimal
is not an - option to- HostnameLookups
. +HostnameLookups minimal
.minimal
is not an + option to+ HostnameLookups
.- To embed spaces in directive arguments NCSA used a backslash before the space. Apache treats backslashes as normal characters. To diff --git a/docs/manual/misc/descriptors.html b/docs/manual/misc/descriptors.html index db028bf907..5841e10e1e 100644 --- a/docs/manual/misc/descriptors.html +++ b/docs/manual/misc/descriptors.html @@ -15,11 +15,11 @@
Descriptors and Apache
-A descriptor, also commonly called a file handle is +
A descriptor, also commonly called a file handle is an object that a program uses to read or write an open file, or open network socket, or a variety of other devices. It is represented -by an integer, and you may be familiar with
stdin
, -stdout
, andstderr
which are descriptors 0, +by an integer, and you may be familiar withstdin
, +stdout
, andstderr
which are descriptors 0, 1, and 2 respectively. Apache needs a descriptor for each log file, plus one for each network socket that it listens on, plus a handful of others. Libraries @@ -28,7 +28,7 @@ open up many descriptors at all, and so there are some latent problems that you may experience should you start running Apache with many descriptors (i.e. with many virtual hosts). -The operating system enforces a limit on the number of descriptors +
The operating system enforces a limit on the number of descriptors that a program can have open at a time. There are typically three limits involved here. One is a kernel limitation, depending on your operating system you will either be able to tune the number of descriptors available @@ -44,49 +44,49 @@ Root can raise the hard limit up to the system maximum limit. The soft limit is the actual limit that is used when enforcing the maximum number of files a process can have open. -
To summarize: +
To summarize: -
- ++ #open files <= soft limit <= hard limit <= kernel limit -You control the hard and soft limits using the
limit
(csh) -orulimit
(sh) directives. See the respective man pages +You control the hard and soft limits using the
limit
(csh) +orulimit
(sh) directives. See the respective man pages for more information. For example you can probably use -ulimit -n unlimited
to raise your soft limit up to the +ulimit -n unlimited
to raise your soft limit up to the hard limit. You should include this command in a shell script which starts your webserver. -Unfortunately, it's not always this simple. As mentioned above, +
Unfortunately, it's not always this simple. As mentioned above, you will probably run into some system limitations that will need to be worked around somehow. Work was done in version 1.2.1 to improve the situation somewhat. Here is a partial list of systems and workarounds (assuming you are using 1.2.1 or later): -
+
--
+- BSDI 2.0 -
- Under BSDI 2.0 you can build Apache to support more descriptors - by adding
-DFD_SETSIZE=nnn
to -EXTRA_CFLAGS
(where nnn is the number of descriptors +- BSDI 2.0 +
- Under BSDI 2.0 you can build Apache to support more descriptors + by adding
-DFD_SETSIZE=nnn
to +EXTRA_CFLAGS
(where nnn is the number of descriptors you wish to support, keep it less than the hard limit). But it will run into trouble if more than approximately 240 Listen directives are used. This may be cured by rebuilding your kernel with a higher FD_SETSIZE. -+
-
- FreeBSD 2.2, BSDI 2.1+ -
- Similar to the BSDI 2.0 case, you should define -
FD_SETSIZE
and rebuild. But the extra +- FreeBSD 2.2, BSDI 2.1+ +
- Similar to the BSDI 2.0 case, you should define +
FD_SETSIZE
and rebuild. But the extra Listen limitation doesn't exist. -+
-
- Linux -
- By default Linux has a kernel maximum of 256 open descriptors +
- Linux +
- By default Linux has a kernel maximum of 256 open descriptors per process. There are several patches available for the 2.0.x series which raise this to 1024 and beyond, and you - can find them in the "unofficial patches" section of the Linux Information HQ. + can find them in the "unofficial patches" section of the Linux Information HQ. None of these patches are perfect, and an entirely different approach is likely to be taken during the 2.1.x development. Applying these patches will raise the FD_SETSIZE used to compile @@ -95,34 +95,34 @@ situation somewhat. Here is a partial list of systems and workarounds 256. As of this writing the patches available for increasing the number of descriptors do not take this into account. On a dedicated webserver you probably won't run into trouble. -
+
-
- Solaris through 2.5.1 -
- Solaris has a kernel hard limit of 1024 (may be lower in earlier +
- Solaris through 2.5.1 +
- Solaris has a kernel hard limit of 1024 (may be lower in earlier versions). But it has a limitation that files using the stdio library cannot have a descriptor above 255. Apache uses the stdio library for the ErrorLog directive. When you have more than approximately 110 virtual hosts (with an error log and an access log each) you will need to - build Apache with
-DHIGH_SLACK_LINE=256
added to -EXTRA_CFLAGS
. You will be limited to approximately + build Apache with-DHIGH_SLACK_LINE=256
added to +EXTRA_CFLAGS
. You will be limited to approximately 240 error logs if you do this. -+
-
- AIX -
- AIX version 3.2?? appears to have a hard limit of 128 descriptors. +
- AIX +
- AIX version 3.2?? appears to have a hard limit of 128 descriptors. End of story. Version 4.1.5 has a hard limit of 2000. -
+
-
- Others -
- If you have details on another operating system, please submit - it through our Bug - Report Page. -
+
- Others +
- If you have details on another operating system, please submit + it through our Bug + Report Page. +
-
In addition to the problems described above there are problems with +
In addition to the problems described above there are problems with many libraries that Apache uses. The most common example is the bind DNS resolver library that is used by pretty much every unix, which fails if it ends up with a descriptor above 256. We suspect there @@ -131,23 +131,23 @@ takes a defensive stance and tries to save descriptors less than 16 for use while processing each request. This is called the low slack line. -
Note that this shouldn't waste descriptors. If you really are pushing +
Note that this shouldn't waste descriptors. If you really are pushing the limits and Apache can't get a descriptor above 16 when it wants it, it will settle for one below 16. -
In extreme situations you may want to lower the low slack line, +
In extreme situations you may want to lower the low slack line, but you shouldn't ever need to. For example, lowering it can increase the limits 240 described above under Solaris and BSDI 2.0. But you'll play a delicate balancing game with the descriptors needed to serve a request. Should you want to play this game, the compile -time parameter is
LOW_SLACK_LINE
and there's a tiny -bit of documentation in the header filehttpd.h
. - -Finally, if you suspect that all this slack stuff is causing you -problems, you can disable it. Add
-DNO_SLACK
to -EXTRA_CFLAGS
and rebuild. But please report it to -our Bug -Report Page so that +time parameter isLOW_SLACK_LINE
and there's a tiny +bit of documentation in the header filehttpd.h
. + +Finally, if you suspect that all this slack stuff is causing you +problems, you can disable it. Add
-DNO_SLACK
to +EXTRA_CFLAGS
and rebuild. But please report it to +our Bug +Report Page so that we can investigate. diff --git a/docs/manual/misc/fin_wait_2.html b/docs/manual/misc/fin_wait_2.html index 0027263f8e..135b8b06e0 100644 --- a/docs/manual/misc/fin_wait_2.html +++ b/docs/manual/misc/fin_wait_2.html @@ -21,7 +21,7 @@What is the FIN_WAIT_2 state?
Starting with the Apache 1.2 betas, people are reporting many more connections in the FIN_WAIT_2 state (as reported by -netstat
) than they saw using older versions. When the +netstat
) than they saw using older versions. When the server closes a TCP connection, it sends a packet with the FIN bit sent to the client, which then responds with a packet with the ACK bit set. The client then sends a packet with the FIN bit set to the diff --git a/docs/manual/misc/howto.html b/docs/manual/misc/howto.html index a7d6b38c3c..0fa77d96be 100644 --- a/docs/manual/misc/howto.html +++ b/docs/manual/misc/howto.html @@ -18,49 +18,49 @@Apache HOWTO documentation
How to: --
+- redirect an entire server or directory to a single URL -
- reset your log files -
- stop/restrict robots -
+
- redirect an entire server or directory to a single URL +
- reset your log files +
- stop/restrict robots +
How to redirect an entire server or directory to a single URL
There are two chief ways to redirect all requests for an entire server to a single location: one which requires the use of -
mod_rewrite
, and another which uses a CGI script. +mod_rewrite
, and another which uses a CGI script.First: if all you need to do is migrate a server from one name to -another, simply use the
Redirect
directive, as supplied -bymod_alias
: +another, simply use theRedirect
directive, as supplied +bymod_alias
: --++Redirect / http://www.apache.org/ -Since
Redirect
will forward along the complete path, +Since
Redirect
will forward along the complete path, however, it may not be appropriate - for example, when the directory structure has changed after the move, and you simply want to direct people to the home page. -The best option is to use the standard Apache module
mod_rewrite
. +The best option is to use the standard Apache module
mod_rewrite
. If that module is compiled in, the following lines: -This will send an HTTP 302 Redirect back to the client, and no matter what they gave in the original URL, they'll be sent to "http://www.apache.org". The second option is to set up aRewriteEngine On ++RewriteEngine On RewriteRule /.* http://www.apache.org/ [R] -ScriptAlias
pointing to -a cgi script which outputs a 301 or 302 status and the location +a cgi script which outputs a 301 or 302 status and the location of the other server. -By using a cgi-script you can intercept various requests and -treat them specially, e.g. you might want to intercept POST +
By using a cgi-script you can intercept various requests and +treat them specially, e.g. you might want to intercept POST requests, so that the client isn't redirected to a script on the other server which expects POST information (a redirect will lose the POST information.) You might also want to use a CGI script if you don't @@ -68,17 +68,17 @@ want to compile mod_rewrite into your server.
Here's how to redirect all requests to a script... In the server configuration file, -
+ScriptAlias / /usr/local/httpd/cgi-bin/redirect_scriptand here's a simple perl script to redirect requests: -ScriptAlias / /usr/local/httpd/cgi-bin/redirect_script++#!/usr/local/bin/perl print "Status: 302 Moved Temporarily\r Location: http://www.some.where.else.com/\r\n\r\n"; -
@@ -100,14 +100,14 @@ characters.The correct procedure is to move the logfile, then signal Apache to tell it to reopen the logfiles.
-Apache is signaled using the SIGHUP (-1) signal. e.g. -
-+
Apache is signaled using the SIGHUP (-1) signal. e.g. +
+mv access_log access_log.old
kill -1 `cat httpd.pid` -Note:
httpd.pid
is a file containing the process id +Note:
@@ -118,16 +118,16 @@ nightly or weekly basis.httpd.pid
is a file containing the process id of the Apache httpd daemon, Apache saves this in the same directory as the log files.How to stop or restrict robots
Ever wondered why so many clients are interested in a file called -
+robots.txt
which you don't have, and never did have?robots.txt
which you don't have, and never did have? -These clients are called robots (also known as crawlers, +
These clients are called robots (also known as crawlers, spiders and other cute name) - special automated clients which wander around the web looking for interesting resources.
-Most robots are used to generate some kind of web index which -is then used by a search engine to help locate information.
+Most robots are used to generate some kind of web index which +is then used by a search engine to help locate information.
-
robots.txt
provides a means to request that robots limit their +
robots.txt
provides a means to request that robots limit their activities at the site, or more often than not, to leave the site alone.When the first robots were developed, they had a bad reputation for diff --git a/docs/manual/misc/index.html b/docs/manual/misc/index.html index b8a5608b32..b9eb945cc3 100644 --- a/docs/manual/misc/index.html +++ b/docs/manual/misc/index.html @@ -13,7 +13,7 @@ ALINK="#FF0000" > -
Apache Miscellaneous Documentation
+Apache Miscellaneous Documentation
Below is a list of additional documentation pages that apply to the diff --git a/docs/manual/misc/known_client_problems.html b/docs/manual/misc/known_client_problems.html index fddb1c25f8..59de0de7bb 100644 --- a/docs/manual/misc/known_client_problems.html +++ b/docs/manual/misc/known_client_problems.html @@ -15,119 +15,119 @@
Known Problems in Clients
-Over time the Apache Group has discovered or been notified of problems +
Over time the Apache Group has discovered or been notified of problems with various clients which we have had to work around. This document describes these problems and the workarounds available. It's not arranged in any particular order. Some familiarity with the standards is assumed, but not necessary. -
For brevity, Navigator will refer to Netscape's Navigator -product, and MSIE will refer to Microsoft's Internet Explorer +
For brevity, Navigator will refer to Netscape's Navigator +product, and MSIE will refer to Microsoft's Internet Explorer product. All trademarks and copyrights belong to their respective companies. We welcome input from the various client authors to correct inconsistencies in this paper, or to provide us with exact version numbers where things are broken/fixed. -
For reference, -RFC1945 +
For reference, +RFC1945 defines HTTP/1.0, and -RFC2068 +RFC2068 defines HTTP/1.1. Apache as of version 1.2 is an HTTP/1.1 server (with an optional HTTP/1.0 proxy). -
Various of these workarounds are triggered by environment variables. +
Various of these workarounds are triggered by environment variables. The admin typically controls which are set, and for which clients, by using -mod_browser. Unless otherwise +mod_browser. Unless otherwise noted all of these workarounds exist in versions 1.2 and later. -
Trailing CRLF on POSTs
+Trailing CRLF on POSTs
-This is a legacy issue. The CERN webserver required
POST
-data to have an extraCRLF
following it. Thus many -clients send an extraCRLF
that -is not included in theContent-Length
of the request. +This is a legacy issue. The CERN webserver required
POST
+data to have an extraCRLF
following it. Thus many +clients send an extraCRLF
that +is not included in theContent-Length
of the request. Apache works around this problem by eating any empty lines which appear before a request. -Broken keepalive
+Broken keepalive
-Various clients have had broken implementations of keepalive +
Various clients have had broken implementations of keepalive (persistent connections). In particular the Windows versions of Navigator 2.0 get very confused when the server times out an idle connection. The workaround is present in the default config files: -
Note that this matches some earlier versions of MSIE, which began the -practice of calling themselves Mozilla in their user-agent +practice of calling themselves Mozilla in their user-agent strings just like Navigator. -+
+BrowserMatch Mozilla/2 nokeepalive -
MSIE 4.0b2, which claims to support HTTP/1.1, does not properly +
MSIE 4.0b2, which claims to support HTTP/1.1, does not properly support keepalive when it is used on 301 or 302 (redirect) -responses. Unfortunately Apache's
nokeepalive
code +responses. Unfortunately Apache'snokeepalive
code prior to 1.2.2 would not work with HTTP/1.1 clients. You must apply -this -patch to version 1.2.1. Then add this to your config: --+this +patch to version 1.2.1. Then add this to your config: +
+BrowserMatch "MSIE 4\.0b2;" nokeepalive -
Incorrect interpretation of
+HTTP/1.1
in responseIncorrect interpretation of
-HTTP/1.1
in responseTo quote from section 3.1 of RFC1945: -
-HTTP uses a "Since Apache is an HTTP/1.1 server, it indicates so as part of its response. Many client authors mistakenly treat this part of the response as an indication of the protocol that the response is in, and then refuse to accept the response. -. " numbering scheme to indicate versions + To quote from section 3.1 of RFC1945: +
+HTTP uses a "+. " numbering scheme to indicate versions of the protocol. The protocol versioning policy is intended to allow the sender to indicate the format of a message and its capacity for understanding further HTTP communication, rather than the features obtained via that communication. - The first major indication of this problem was with AOL's proxy servers. +
The first major indication of this problem was with AOL's proxy servers. When Apache 1.2 went into beta it was the first wide-spread HTTP/1.1 server. After some discussion, AOL fixed their proxies. In -anticipation of similar problems, the
force-response-1.0
+anticipation of similar problems, theforce-response-1.0
environment variable was added to Apache. When present Apache will indicate "HTTP/1.0" in response to an HTTP/1.0 client, but will not in any other way change the response. -The pre-1.1 Java Development Kit (JDK) that is used in many clients +
The pre-1.1 Java Development Kit (JDK) that is used in many clients (including Navigator 3.x and MSIE 3.x) exhibits this problem. As do some of the early pre-releases of the 1.1 JDK. We think it is fixed in the 1.1 JDK release. In any event the workaround: -
--BrowserMatch Java1.0 force-response-1.0
+++BrowserMatch Java1.0 force-response-1.0
BrowserMatch JDK/1.0 force-response-1.0 -RealPlayer 4.0 from Progressive Networks also exhibits this problem. +
RealPlayer 4.0 from Progressive Networks also exhibits this problem. However they have fixed it in version 4.01 of the player, but version -4.01 uses the same
User-Agent
as version 4.0. The +4.01 uses the sameUser-Agent
as version 4.0. The workaround is still: --+
+BrowserMatch "RealPlayer 4.0" force-response-1.0 -
Requests use HTTP/1.1 but responses must be in HTTP/1.0
+Requests use HTTP/1.1 but responses must be in HTTP/1.0
-MSIE 4.0b2 has this problem. Its Java VM makes requests in HTTP/1.1 +
MSIE 4.0b2 has this problem. Its Java VM makes requests in HTTP/1.1 format but the responses must be in HTTP/1.0 format (in particular, it -does not understand chunked responses). The workaround +does not understand chunked responses). The workaround is to fool Apache into believing the request came in HTTP/1.0 format. -
This workaround is available in 1.2.2, and in a -patch - against 1.2.1. +patch + against 1.2.1. -+
+BrowserMatch "MSIE 4\.0b2;" downgrade-1.0 force-response-1.0 -
Boundary problems with header parsing
+Boundary problems with header parsing
-All versions of Navigator from 2.0 through 4.0b2 (and possibly later) +
All versions of Navigator from 2.0 through 4.0b2 (and possibly later) have a problem if the trailing CRLF of the response header starts at offset 256, 257 or 258 of the response. A BrowserMatch for this would match on nearly every hit, so the workaround is enabled automatically @@ -135,18 +135,18 @@ on all responses. The workaround is to detect when this condition would occur in a response and add extra padding to the header to push the trailing CRLF past offset 258 of the response. -
Multipart responses and Quoted Boundary Strings
+Multipart responses and Quoted Boundary Strings
-On multipart responses some clients will not accept quotes (") +
On multipart responses some clients will not accept quotes (") around the boundary string. The MIME standard recommends that such quotes be used. But the clients were probably written based on one of the examples in RFC2068, which does not include quotes. Apache does not include quotes on its boundary strings to workaround this problem. -
Byterange requests
+Byterange requests
-A byterange request is used when the client wishes to retrieve a +
A byterange request is used when the client wishes to retrieve a portion of an object, not necessarily the entire object. There was a very old draft which included these byteranges in the URL. Old clients such as Navigator 2.0b1 and MSIE 3.0 for the MAC @@ -155,66 +155,66 @@ it will appear in the servers' access logs as (failed) attempts to retrieve a URL with a trailing ";xxx-yyy". Apache does not attempt to implement this at all. -
A subsequent draft of this standard defines a header -
Request-Range
, and a response type -multipart/x-byteranges
. The HTTP/1.1 standard includes +A subsequent draft of this standard defines a header +
Request-Range
, and a response type +multipart/x-byteranges
. The HTTP/1.1 standard includes this draft with a few fixes, and it defines the header -Range
and typemultipart/byteranges
. - -Navigator (versions 2 and 3) sends both
Range
and -Request-Range
headers (with the same value), but does not -accept amultipart/byteranges
response. The response must -bemultipart/x-byteranges
. As a workaround, if Apache -receives aRequest-Range
header it considers it "higher -priority" than aRange
header and in response uses -multipart/x-byteranges
. - -The Adobe Acrobat Reader plugin makes extensive use of byteranges and -prior to version 3.01 supports only the
multipart/x-byterange
+Range
and typemultipart/byteranges
. + +Navigator (versions 2 and 3) sends both
Range
and +Request-Range
headers (with the same value), but does not +accept amultipart/byteranges
response. The response must +bemultipart/x-byteranges
. As a workaround, if Apache +receives aRequest-Range
header it considers it "higher +priority" than aRange
header and in response uses +multipart/x-byteranges
. + +The Adobe Acrobat Reader plugin makes extensive use of byteranges and +prior to version 3.01 supports only the
multipart/x-byterange
response. Unfortunately there is no clue that it is the plugin making the request. If the plugin is used with Navigator, the above workaround works fine. But if the plugin is used with MSIE 3 (on Windows) the workaround won't work because MSIE 3 doesn't give the -Range-Request
clue that Navigator does. To workaround this, -Apache special cases "MSIE 3" in theUser-Agent
and serves -multipart/x-byteranges
. Note that the necessity for this +Range-Request
clue that Navigator does. To workaround this, +Apache special cases "MSIE 3" in theUser-Agent
and serves +multipart/x-byteranges
. Note that the necessity for this with MSIE 3 is actually due to the Acrobat plugin, not due to the browser. -Netscape Communicator appears to not issue the non-standard -
Request-Range
header. When an Acrobat plugin prior to +Netscape Communicator appears to not issue the non-standard +
Request-Range
header. When an Acrobat plugin prior to version 3.01 is used with it, it will not properly understand byteranges. The user must upgrade their Acrobat reader to 3.01. -+
Set-Cookie
header is unmergeable-
Set-Cookie
header is unmergeableThe HTTP specifications say that it is legal to merge headers with +
The HTTP specifications say that it is legal to merge headers with duplicate names into one (separated by semicolon). Some browsers that support Cookies don't like merged headers and prefer that each -
Set-Cookie
header is sent separately. When parsing the +Set-Cookie
header is sent separately. When parsing the headers returned by a CGI, Apache will explicitly avoid merging any -Set-Cookie
headers. +Set-Cookie
headers. -+
Expires
headers and GIF89A animations-
Expires
headers and GIF89A animationsNavigator versions 2 through 4 will erroneously re-request +
Navigator versions 2 through 4 will erroneously re-request GIF89A animations on each loop of the animation if the first -response included an
Expires
header. This happens +response included anExpires
header. This happens regardless of how far in the future the expiry time is set. There -is no workaround supplied with Apache, however there are hacks for 1.2 -and for 1.3. +is no workaround supplied with Apache, however there are hacks for 1.2 +and for 1.3. -+
POST
withoutContent-Length
-
POST
withoutContent-Length
In certain situations Navigator 3.01 through 3.03 appear to incorrectly +
In certain situations Navigator 3.01 through 3.03 appear to incorrectly issue a POST without the request body. There is no known workaround. It has been fixed in Navigator 3.04, Netscapes provides some -information. +information. There's also - -some information about the actual problem. + +some information about the actual problem. diff --git a/docs/manual/misc/perf-tuning.html b/docs/manual/misc/perf-tuning.html index f75fbf926b..33aab731a6 100644 --- a/docs/manual/misc/perf-tuning.html +++ b/docs/manual/misc/perf-tuning.html @@ -1,15 +1,15 @@ - -
-Apache Performance Notes - + + +Apache Performance Notes + -Apache Performance Notes
+Apache Performance Notes
-Author: Dean Gaudet +
Author: Dean Gaudet
Introduction
-Apache is a general webserver, which is designed to be correct first, and +
Apache is a general webserver, which is designed to be correct first, and fast second. Even so, it's performance is quite satisfactory. Most sites have less than 10Mbits of outgoing bandwidth, which Apache can fill using only a low end Pentium-based webserver. In practice sites @@ -18,7 +18,7 @@ due to other constraints (such as CGI or database transaction overhead). For these reasons the development focus has been mostly on correctness and configurability. -
Unfortunately many folks overlook these facts and cite raw performance +
Unfortunately many folks overlook these facts and cite raw performance numbers as if they are some indication of the quality of a web server product. There is a bare minimum performance that is acceptable, beyond that extra speed only caters to a much smaller segment of the market. @@ -26,32 +26,32 @@ But in order to avoid this hurdle to the acceptance of Apache in some markets, effort was put into Apache 1.3 to bring performance up to a point where the difference with other high-end webservers is minimal. -
Finally there are the folks who just plain want to see how fast something +
Finally there are the folks who just plain want to see how fast something can go. The author falls into this category. The rest of this document is dedicated to these folks who want to squeeze every last bit of performance out of Apache's current model, and want to understand why it does some things which slow it down. -
Note that this is tailored towards Apache 1.3 on Unix. Some of it applies +
Note that this is tailored towards Apache 1.3 on Unix. Some of it applies to Apache on NT. Apache on NT has not been tuned for performance yet, in fact it probably performs very poorly because NT performance requires a different programming model.
Hardware and Operating System Issues
-The single biggest hardware issue affecting webserver performance +
The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, swapping increases the latency of each request beyond a point that users consider "fast enough". This causes users to hit stop and reload, further increasing -the load. You can, and should, control the
MaxClients
+the load. You can, and should, control theMaxClients
setting so that your server does not spawn so many children it starts swapping. -Beyond that the rest is mundane: get a fast enough CPU, a fast enough +
Beyond that the rest is mundane: get a fast enough CPU, a fast enough network card, and fast enough disks, where "fast enough" is something that needs to be determined by experimentation. -
Operating system choice is largely a matter of local concerns. But +
Operating system choice is largely a matter of local concerns. But a general guideline is to always apply the latest vendor TCP/IP patches. HTTP serving completely breaks many of the assumptions built into Unix kernels up through 1994 and even 1995. Good choices include @@ -60,56 +60,56 @@ recent FreeBSD, and Linux.
Run-Time Configuration Issues
HostnameLookups
-Prior to Apache 1.3,
HostnameLookups
defaulted to On. +Prior to Apache 1.3,
HostnameLookups
defaulted to On. This adds latency to every request because it requires a DNS lookup to complete before the request is finished. In Apache 1.3 this setting defaults to Off. -However (1.3 or later), if you use anyallow from domain
or -deny from domain
directives then you will pay for a +However (1.3 or later), if you use anyallow from domain
or +deny from domain
directives then you will pay for a double reverse DNS lookup (a reverse, followed by a forward to make sure that the reverse is not being spoofed). So for the highest performance avoid using these directives (it's fine to use IP addresses rather than domain names). -Note that it's possible to scope the directives, such as within -a
<Location /server-status>
section. In this +Note that it's possible to scope the directives, such as within +a
<Location /server-status>
section. In this case the DNS lookups are only performed on requests matching the criteria. Here's an example which disables lookups except for .html and .cgi files: -But even still, if you just need DNS names in some CGIs you could consider doing the -++HostnameLookups off <Files ~ "\.(html|cgi)$> HostnameLookups on </Files> -gethostbyname
call in the specific CGIs that need it. +gethostbyname
call in the specific CGIs that need it.FollowSymLinks and SymLinksIfOwnerMatch
-Wherever in your URL-space you do not have an -
Options FollowSymLinks
, or you do have an -Options SymLinksIfOwnerMatch
Apache will have to +Wherever in your URL-space you do not have an +
Options FollowSymLinks
, or you do have an +Options SymLinksIfOwnerMatch
Apache will have to issue extra system calls to check up on symlinks. One extra call per filename component. For example, if you had: --and a request is made for the URI++DocumentRoot /www/htdocs <Directory /> Options SymLinksIfOwnerMatch </Directory> -/index.html
. -Then Apache will performlstat(2)
on/www
, -/www/htdocs
, and/www/htdocs/index.html
. The -results of theselstats
are never cached, +and a request is made for the URI/index.html
. +Then Apache will performlstat(2)
on/www
, +/www/htdocs
, and/www/htdocs/index.html
. The +results of theselstats
are never cached, so they will occur on every single request. If you really desire the symlinks security checking you can do something like this: --This at least avoids the extra checks for the++DocumentRoot /www/htdocs <Directory /> Options FollowSymLinks @@ -117,72 +117,72 @@ DocumentRoot /www/htdocs <Directory /www/htdocs> Options -FollowSymLinks +SymLinksIfOwnerMatch </Directory> -DocumentRoot
+This at least avoids the extra checks for theDocumentRoot
path. Note that you'll need to add similar sections if you have any -Alias
orRewriteRule
paths outside of your +Alias
orRewriteRule
paths outside of your document root. For highest performance, and no symlink protection, -setFollowSymLinks
everywhere, and never set -SymLinksIfOwnerMatch
. +setFollowSymLinks
everywhere, and never set +SymLinksIfOwnerMatch
.AllowOverride
-Wherever in your URL-space you allow overrides (typically -
.htaccess
files) Apache will attempt to open -.htaccess
for each filename component. For example, +Wherever in your URL-space you allow overrides (typically +
.htaccess
files) Apache will attempt to open +.htaccess
for each filename component. For example, --and a request is made for the URI++DocumentRoot /www/htdocs <Directory /> AllowOverride all </Directory> -/index.html
. Then -Apache will attempt to open/.htaccess
, -/www/.htaccess
, and/www/htdocs/.htaccess
. -The solutions are similar to the previous case ofOptions -FollowSymLinks
. For highest performance use -AllowOverride None
everywhere in your filesystem. +and a request is made for the URI/index.html
. Then +Apache will attempt to open/.htaccess
, +/www/.htaccess
, and/www/htdocs/.htaccess
. +The solutions are similar to the previous case ofOptions +FollowSymLinks
. For highest performance use +AllowOverride None
everywhere in your filesystem.Negotiation
-If at all possible, avoid content-negotiation if you're really +
If at all possible, avoid content-negotiation if you're really interested in every last ounce of performance. In practice the benefits of negotiation outweigh the performance penalties. There's one case where you can speed up the server. Instead of using a wildcard such as: -
Use a complete list of options: -++DirectoryIndex index -where you list the most common choice first.++DirectoryIndex index.cgi index.pl index.shtml index.html -Process Creation
-Prior to Apache 1.3 the
MinSpareServers
, -MaxSpareServers
, andStartServers
settings +Prior to Apache 1.3 the
MinSpareServers
, +MaxSpareServers
, andStartServers
settings all had drastic effects on benchmark results. In particular, Apache required a "ramp-up" period in order to reach a number of children sufficient to serve the load being applied. After the initial -spawning ofStartServers
children, only one child per -second would be created to satisfy theMinSpareServers
+spawning ofStartServers
children, only one child per +second would be created to satisfy theMinSpareServers
setting. So a server being accessed by 100 simultaneous clients, -using the defaultStartServers
of 5 would take on +using the defaultStartServers
of 5 would take on the order 95 seconds to spawn enough children to handle the load. This works fine in practice on real-life servers, because they aren't restarted frequently. But does really poorly on benchmarks which might only run for ten minutes. -The one-per-second rule was implemented in an effort to avoid +
The one-per-second rule was implemented in an effort to avoid swamping the machine with the startup of new children. If the machine is busy spawning children it can't service requests. But it has such a drastic effect on the perceived performance of Apache that it had @@ -191,61 +191,61 @@ the code will relax the one-per-second rule. It will spawn one, wait a second, then spawn two, wait a second, then spawn four, and it will continue exponentially until it is spawning 32 children per second. It will stop whenever it satisfies the -
MinSpareServers
setting. +MinSpareServers
setting. -This appears to be responsive enough that it's -almost unnecessary to twiddle the
MinSpareServers
, -MaxSpareServers
andStartServers
knobs. When +This appears to be responsive enough that it's +almost unnecessary to twiddle the
MinSpareServers
, +MaxSpareServers
andStartServers
knobs. When more than 4 children are spawned per second, a message will be emitted -to theErrorLog
. If you see a lot of these errors then -consider tuning these settings. Use themod_status
output +to theErrorLog
. If you see a lot of these errors then +consider tuning these settings. Use themod_status
output as a guide. -Related to process creation is process death induced by the -
MaxRequestsPerChild
setting. By default this is 30, which +Related to process creation is process death induced by the +
MaxRequestsPerChild
setting. By default this is 30, which is probably far too low unless your server is using a module such as -mod_perl
which causes children to have bloated memory +mod_perl
which causes children to have bloated memory images. If your server is serving mostly static pages then consider raising this value to something like 10000. The code is robust enough that this shouldn't be a problem. -When keep-alives are in use, children will be kept busy +
When keep-alives are in use, children will be kept busy doing nothing waiting for more requests on the already open -connection. The default
KeepAliveTimeout
of +connection. The defaultKeepAliveTimeout
of 15 seconds attempts to minimize this effect. The tradeoff here is between network bandwidth and server resources. In no event should you raise this above about 60 seconds, as - -most of the benefits are lost. + +most of the benefits are lost.Compile-Time Configuration Issues
mod_status and Rule STATUS=yes
-If you include
mod_status
-and you also setRule STATUS=yes
when building +If you include
mod_status
+and you also setRule STATUS=yes
when building Apache, then on every request Apache will perform two calls to -gettimeofday(2)
(ortimes(2)
depending +gettimeofday(2)
(ortimes(2)
depending on your operating system), and (pre-1.3) several extra calls to -time(2)
. This is all done so that the status report -contains timing indications. For highest performance, setRule -STATUS=no
. +time(2)
. This is all done so that the status report +contains timing indications. For highest performance, setRule +STATUS=no
.accept Serialization - multiple sockets
-This discusses a shortcoming in the Unix socket API. +
This discusses a shortcoming in the Unix socket API. Suppose your -web server uses multiple
Listen
statements to listen on +web server uses multipleListen
statements to listen on either multiple ports or multiple addresses. In order to test each -socket to see if a connection is ready Apache usesselect(2)
. -select(2)
indicates that a socket has none or -at least one connection waiting on it. Apache's model includes +socket to see if a connection is ready Apache usesselect(2)
. +select(2)
indicates that a socket has none or +at least one connection waiting on it. Apache's model includes multiple children, and all the idle ones test for new connections at the same time. A naive implementation looks something like this (these examples do not match the code, they're contrived for pedagogical purposes): -But this naive implementation has a serious starvation problem. Recall that multiple children execute this loop at the same time, and so multiple -children will block at++for (;;) { for (;;) { fd_set accept_fds; @@ -267,43 +267,43 @@ pedagogical purposes): } process the new_connection; } -select
when they are in between +children will block atselect
when they are in between requests. All those blocked children will awaken and return from -select
when a single request appears on any socket +select
when a single request appears on any socket (the number of children which awaken varies depending on the operating system and timing issues). -They will all then fall down into the loop and try toaccept
+They will all then fall down into the loop and try toaccept
the connection. But only one will succeed (assuming there's still only -one connection ready), the rest will be blocked inaccept
. +one connection ready), the rest will be blocked inaccept
. This effectively locks those children into serving requests from that one socket and no other sockets, and they'll be stuck there until enough new requests appear on that socket to wake them all up. This starvation problem was first documented in -PR#467. There +PR#467. There are at least two solutions. -One solution is to make the sockets non-blocking. In this case the -
accept
won't block the children, and they will be allowed +One solution is to make the sockets non-blocking. In this case the +
accept
won't block the children, and they will be allowed to continue immediately. But this wastes CPU time. Suppose you have -ten idle children inselect
, and one connection arrives. -Then nine of those children will wake up, try toaccept
the -connection, fail, and loop back intoselect
, accomplishing +ten idle children inselect
, and one connection arrives. +Then nine of those children will wake up, try toaccept
the +connection, fail, and loop back intoselect
, accomplishing nothing. Meanwhile none of those children are servicing requests that -occurred on other sockets until they get back up to theselect
+occurred on other sockets until they get back up to theselect
again. Overall this solution does not seem very fruitful unless you have as many idle CPUs (in a multiprocessor box) as you have idle children, not a very likely situation. -Another solution, the one used by Apache, is to serialize entry into +
Another solution, the one used by Apache, is to serialize entry into the inner loop. The loop looks like this (differences highlighted): -
- -The functions++for (;;) { - accept_mutex_on (); + accept_mutex_on (); for (;;) { fd_set accept_fds; @@ -322,64 +322,64 @@ the inner loop. The loop looks like this (differences highlighted): } if (new_connection != -1) break; } - accept_mutex_off (); + accept_mutex_off (); process the new_connection; } -accept_mutex_on
andaccept_mutex_off
+ +The functionsaccept_mutex_on
andaccept_mutex_off
implement a mutual exclusion semaphore. Only one child can have the mutex at any time. There are several choices for implementing these -mutexes. The choice is defined insrc/conf.h
(pre-1.3) or -src/main/conf.h
(1.3 or later). Some architectures +mutexes. The choice is defined insrc/conf.h
(pre-1.3) or +src/main/conf.h
(1.3 or later). Some architectures do not have any locking choice made, on these architectures it is unsafe -to use multipleListen
directives. +to use multipleListen
directives. --
-USE_FLOCK_SERIALIZED_ACCEPT
-- This method uses the
flock(2)
system call to lock a -lock file (located by theLockFile
directive). ++
+USE_FLOCK_SERIALIZED_ACCEPT
+- This method uses the
flock(2)
system call to lock a +lock file (located by theLockFile
directive). -USE_FCNTL_SERIALIZED_ACCEPT
-- This method uses the
fcntl(2)
system call to lock a -lock file (located by theLockFile
directive). +USE_FCNTL_SERIALIZED_ACCEPT
+- This method uses the
fcntl(2)
system call to lock a +lock file (located by theLockFile
directive). -USE_SYSVSEM_SERIALIZED_ACCEPT
-- (1.3 or later) This method uses SysV-style semaphores to implement the +
USE_SYSVSEM_SERIALIZED_ACCEPT
+- (1.3 or later) This method uses SysV-style semaphores to implement the mutex. Unfortunately SysV-style semaphores have some bad side-effects. One is that it's possible Apache will die without cleaning up the semaphore -(see the
ipcs(8)
man page). The other is that the semaphore +(see theipcs(8)
man page). The other is that the semaphore API allows for a denial of service attack by any CGIs running under the same uid as the webserver (i.e. all CGIs unless you use something like suexec or cgiwrapper). For these reasons this method is not used on any architecture except IRIX (where the previous two are prohibitively expensive on most IRIX boxes). -USE_USLOCK_SERIALIZED_ACCEPT
-- (1.3 or later) This method is only available on IRIX, and uses -
usconfig(2)
to create a mutex. While this method avoids +USE_USLOCK_SERIALIZED_ACCEPT
+- (1.3 or later) This method is only available on IRIX, and uses +
usconfig(2)
to create a mutex. While this method avoids the hassles of SysV-style semaphores, it is not the default for IRIX. This is because on single processor IRIX boxes (5.3 or 6.2) the uslock code is two orders of magnitude slower than the SysV-semaphore code. On multi-processor IRIX boxes the uslock code is an order of magnitude faster than the SysV-semaphore code. Kind of a messed up situation. So if you're using a multiprocessor IRIX box then you should rebuild your -webserver with-DUSE_USLOCK_SERIALIZED_ACCEPT
on the -EXTRA_CFLAGS
. +webserver with-DUSE_USLOCK_SERIALIZED_ACCEPT
on the +EXTRA_CFLAGS
. -USE_PTHREAD_SERIALIZED_ACCEPT
-- (1.3 or later) This method uses POSIX mutexes and should work on +
USE_PTHREAD_SERIALIZED_ACCEPT
+- (1.3 or later) This method uses POSIX mutexes and should work on any architecture implementing the full POSIX threads specification, however appears to only work on Solaris (2.5 or later). This is the default for Solaris 2.5 or later. -
If your system has another method of serialization which isn't in the +
If your system has another method of serialization which isn't in the above list then it may be worthwhile adding code for it (and submitting a patch back to Apache). -
Another solution that has been considered but never implemented is +
Another solution that has been considered but never implemented is to partially serialize the loop -- that is, let in a certain number of processes. This would only be of interest on multiprocessor boxes where it's possible multiple children could run simultaneously, and the @@ -387,26 +387,26 @@ serialization actually doesn't take advantage of the full bandwidth. This is a possible area of future investigation, but priority remains low because highly parallel web servers are not the norm. -
Ideally you should run servers without multiple
Listen
+Ideally you should run servers without multiple
Listen
statements if you want the highest performance. But read on.accept Serialization - single socket
-The above is fine and dandy for multiple socket servers, but what +
The above is fine and dandy for multiple socket servers, but what about single socket servers? In theory they shouldn't experience any of these same problems because all children can just block in -
accept(2)
until a connection arrives, and no starvation +accept(2)
until a connection arrives, and no starvation results. In practice this hides almost the same "spinning" behaviour discussed above in the non-blocking solution. The way that most TCP stacks are implemented, the kernel actually wakes up all processes blocked -inaccept
when a single connection arrives. One of those +inaccept
when a single connection arrives. One of those processes gets the connection and returns to user-space, the rest spin in the kernel and go back to sleep when they discover there's no connection for them. This spinning is hidden from the user-land code, but it's there nonetheless. This can result in the same load-spiking wasteful behaviour that a non-blocking solution to the multiple sockets case can. -For this reason we have found that many architectures behave more +
For this reason we have found that many architectures behave more "nicely" if we serialize even the single socket case. So this is actually the default in almost all cases. Crude experiments under Linux (2.0.30 on a dual Pentium pro 166 w/128Mb RAM) have shown that @@ -415,20 +415,20 @@ decrease in requests per second over unserialized single-socket. But unserialized single-socket showed an extra 100ms latency on each request. This latency is probably a wash on long haul lines, and only an issue on LANs. If you want to override the single socket -serialization you can define
SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+serialization you can defineSINGLE_LISTEN_UNSERIALIZED_ACCEPT
and then single-socket servers will not serialize at all.Lingering Close
-As discussed in -draft-ietf-http-connection-00.txt section 8, -in order for an HTTP server to reliably implement the protocol +
As discussed in +draft-ietf-http-connection-00.txt section 8, +in order for an HTTP server to reliably implement the protocol it needs to shutdown each direction of the communication independently (recall that a TCP connection is bi-directional, each half is independent of the other). This fact is often overlooked by other servers, but is correctly implemented in Apache as of 1.2. -
When this feature was added to Apache it caused a flurry of +
When this feature was added to Apache it caused a flurry of problems on various versions of Unix because of a shortsightedness. The TCP specification does not state that the FIN_WAIT_2 state has a timeout, but it doesn't prohibit it. On systems without the timeout, @@ -438,17 +438,17 @@ TCP/IP patches supplied by the vendor, in cases where the vendor has never released patches (i.e. SunOS4 -- although folks with a source license can patch it themselves) we have decided to disable this feature. -
There are two ways of accomplishing this. One is the -socket option
SO_LINGER
. But as fate would have it, +There are two ways of accomplishing this. One is the +socket option
SO_LINGER
. But as fate would have it, this has never been implemented properly in most TCP/IP stacks. Even on those stacks with a proper implementation (i.e. Linux 2.0.31) this method proves to be more expensive (cputime) than the next solution. -For the most part, Apache implements this in a function called -
lingering_close
(inhttp_main.c
). The +For the most part, Apache implements this in a function called +
lingering_close
(inhttp_main.c
). The function looks roughly like this: -This naturally adds some expense at the end of a connection, but it is required for a reliable implementation. As HTTP/1.1 becomes more prevalent, and all connections are persistent, this expense will be amortized over more requests. If you want to play with fire and -disable this feature you can define++void lingering_close (int s) { char junk_buffer[2048]; @@ -470,48 +470,48 @@ function looks roughly like this: close (s); } -NO_LINGCLOSE
, but +disable this feature you can defineNO_LINGCLOSE
, but this is not recommended at all. In particular, as HTTP/1.1 pipelined -persistent connections come into uselingering_close
+persistent connections come into uselingering_close
is an absolute necessity (and - -pipelined connections are faster, so you + +pipelined connections are faster, so you want to support them).Scoreboard File
-Apache's parent and children communicate with each other through +
Apache's parent and children communicate with each other through something called the scoreboard. Ideally this should be implemented in shared memory. For those operating systems that we either have access to, or have been given detailed ports for, it typically is implemented using shared memory. The rest default to using an on-disk file. The on-disk file is not only slow, but it is unreliable -(and less featured). Peruse the
src/main/conf.h
file -for your architecture and look for eitherUSE_MMAP_SCOREBOARD
or -USE_SHMGET_SCOREBOARD
. Defining one of those two (as -well as their companionsHAVE_MMAP
andHAVE_SHMGET
+(and less featured). Peruse thesrc/main/conf.h
file +for your architecture and look for eitherUSE_MMAP_SCOREBOARD
or +USE_SHMGET_SCOREBOARD
. Defining one of those two (as +well as their companionsHAVE_MMAP
andHAVE_SHMGET
respectively) enables the supplied shared memory code. If your system has -another type of shared memory, edit the filesrc/main/http_main.c
+another type of shared memory, edit the filesrc/main/http_main.c
and add the hooks necessary to use it in Apache. (Send us back a patch too please.) -Historical note: The Linux port of Apache didn't start to use +
Historical note: The Linux port of Apache didn't start to use shared memory until version 1.2 of Apache. This oversight resulted in really poor and unreliable behaviour of earlier versions of Apache on Linux. -
+
DYNAMIC_MODULE_LIMIT
-
DYNAMIC_MODULE_LIMIT
If you have no intention of using dynamically loaded modules +
If you have no intention of using dynamically loaded modules (you probably don't if you're reading this and tuning your server for every last ounce of performance) then you should add -
-DDYNAMIC_MODULE_LIMIT=0
when building your server. +-DDYNAMIC_MODULE_LIMIT=0
when building your server. This will save RAM that's allocated only for supporting dynamically loaded modules. @@ -520,21 +520,21 @@ loaded modules. Here is a system call trace of Apache 1.3 running on Linux. The run-time configuration file is essentially the default plus: -The file being requested is a static 6K file of no particular content. Traces of non-static requests or requests with content negotiation look wildly different (and quite ugly in some cases). First the entire trace, then we'll examine details. (This was generated by -the++<Directory /> AllowOverride none Options FollowSymLinks </Directory> -strace
program, other similar programs include -truss
,ktrace
, andpar
.) +thestrace
program, other similar programs include +truss
,ktrace
, andpar
.) --++accept(15, {sin_family=AF_INET, sin_port=htons(22283), sin_addr=inet_addr("127.0.0.1")}, [16]) = 3 flock(18, LOCK_UN) = 0 sigaction(SIGUSR1, {SIG_IGN}, {0x8059954, [], SA_INTERRUPT}) = 0 @@ -560,31 +560,31 @@ close(3) = 0 sigaction(SIGUSR1, {0x8059954, [], SA_INTERRUPT}, {SIG_IGN}) = 0 munmap(0x400ee000, 6144) = 0 flock(18, LOCK_EX) = 0 -Notice the accept serialization: +
Notice the accept serialization: -
These two calls can be removed by defining -++flock(18, LOCK_UN) = 0 ... flock(18, LOCK_EX) = 0 -SINGLE_LISTEN_UNSERIALIZED_ACCEPT
as described earlier. +SINGLE_LISTEN_UNSERIALIZED_ACCEPT
as described earlier. -Notice the
SIGUSR1
manipulation: +Notice the
SIGUSR1
manipulation: -This is caused by the implementation of graceful restarts. When the -parent receives a++sigaction(SIGUSR1, {SIG_IGN}, {0x8059954, [], SA_INTERRUPT}) = 0 ... sigaction(SIGUSR1, {SIG_IGN}, {SIG_IGN}) = 0 ... sigaction(SIGUSR1, {0x8059954, [], SA_INTERRUPT}, {SIG_IGN}) = 0 -SIGUSR1
it sends aSIGUSR1
+parent receives aSIGUSR1
it sends aSIGUSR1
to all of its children (and it also increments a "generation counter" in shared memory). Any children that are idle (between connections) will immediately die @@ -593,7 +593,7 @@ connections, but are in between requests will die off immediately. But any children that have a connection and are still waiting for the first request will not die off immediately. -To see why this is necessary, consider how a browser reacts to a closed +
To see why this is necessary, consider how a browser reacts to a closed connection. If the connection was a keep-alive connection and the request being serviced was not the first request then the browser will quietly reissue the request on a new connection. It has to do this because the @@ -605,40 +605,40 @@ dialogue (or a broken image icon). This is done on the assumption that the server is broken in some way (or maybe too overloaded to respond at all). So Apache tries to avoid ever deliberately closing the connection before it has sent a single response. This is the cause of those -
SIGUSR1
manipulations. +SIGUSR1
manipulations. -Note that it is theoretically possible to eliminate all three of +
Note that it is theoretically possible to eliminate all three of these calls. But in rough tests the gain proved to be almost unnoticeable. -
In order to implement virtual hosts, Apache needs to know the +
In order to implement virtual hosts, Apache needs to know the local socket address used to accept the connection: -
It is possible to eliminate this call in many situations (such as when -there are no virtual hosts, or when++getsockname(3, {sin_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0 -Listen
directives are +there are no virtual hosts, or whenListen
directives are used which do not have wildcard addresses). But no effort has yet been made to do these optimizations. -Apache turns off the Nagle algorithm: +
Apache turns off the Nagle algorithm: -
because of problems described in -a -paper by John Heidemann. +a +paper by John Heidemann. -++setsockopt(3, IPPROTO_TCP1, [1], 4) = 0 -Notice the two
time
calls: +Notice the two
time
calls: -One of these occurs at the beginning of the request, and the other occurs as a result of writing the log. At least one of these is required to @@ -647,115 +647,115 @@ Common Log Format dictates that the log record include a timestamp of the end of the request. A custom logging module could eliminate one of the calls. -++time(NULL) = 873959960 ... time(NULL) = 873959960 -As described earlier,
Rule STATUS=yes
causes two -gettimeofday
calls and a call totimes
: +As described earlier,
Rule STATUS=yes
causes two +gettimeofday
calls and a call totimes
: --These can be removed by either removing++gettimeofday({873959960, 404935}, NULL) = 0 ... gettimeofday({873959960, 417742}, NULL) = 0 times({tms_utime=5, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 446747 -mod_status
or -settingRule STATUS=no
. +These can be removed by either removingmod_status
or +settingRule STATUS=no
. -It might seem odd to call
stat
: +It might seem odd to call
stat
: -This is part of the algorithm which calculates the -++stat("/home/dgaudet/ap/apachen/htdocs/6k", {st_mode=S_IFREG|0644, st_size=6144, ...}) = 0 -PATH_INFO
for use by CGIs. In fact if the request had been -for the URI/cgi-bin/printenv/foobar
then there would be -two calls tostat
. The first for -/home/dgaudet/ap/apachen/cgi-bin/printenv/foobar
+PATH_INFO
for use by CGIs. In fact if the request had been +for the URI/cgi-bin/printenv/foobar
then there would be +two calls tostat
. The first for +/home/dgaudet/ap/apachen/cgi-bin/printenv/foobar
which does not exist, and the second for -/home/dgaudet/ap/apachen/cgi-bin/printenv
, which does exist. -Regardless, at least onestat
call is necessary when +/home/dgaudet/ap/apachen/cgi-bin/printenv
, which does exist. +Regardless, at least onestat
call is necessary when serving static files because the file size and modification times are -used to generate HTTP headers (such asContent-Length
, -Last-Modified
) and implement protocol features (such -asIf-Modified-Since
). A somewhat more clever server -could avoid thestat
when serving non-static files, +used to generate HTTP headers (such asContent-Length
, +Last-Modified
) and implement protocol features (such +asIf-Modified-Since
). A somewhat more clever server +could avoid thestat
when serving non-static files, however doing so in Apache is very difficult given the modular structure. -All static files are served using
mmap
: +All static files are served using
mmap
: --On some architectures it's slower to++mmap(0, 6144, PROT_READ, MAP_PRIVATE, 4, 0) = 0x400ee000 ... munmap(0x400ee000, 6144) = 0 -mmap
small -files than it is to simplyread
them. The define -MMAP_THRESHOLD
can be set to the minimum -size required before usingmmap
. By default +On some architectures it's slower tommap
small +files than it is to simplyread
them. The define +MMAP_THRESHOLD
can be set to the minimum +size required before usingmmap
. By default it's set to 0 (except on SunOS4 where experimentation has -shown 8192 to be a better value). Using a tool such as lmbench you +shown 8192 to be a better value). Using a tool such as lmbench you can determine the optimal setting for your environment. -You may also wish to experiment with
MMAP_SEGMENT_SIZE
+You may also wish to experiment with
MMAP_SEGMENT_SIZE
(default 32768) which determines the maximum number of bytes that will be written at a time from mmap()d files. Apache only resets the -client'sTimeout
in between write()s. So setting this +client'sTimeout
in between write()s. So setting this large may lock out low bandwidth clients unless you also increase the -Timeout
. +Timeout
. -It may even be the case that
mmap
isn't -used on your architecture, if so then definingUSE_MMAP_FILES
-andHAVE_MMAP
might work (if it works then report back to us). +It may even be the case that
mmap
isn't +used on your architecture, if so then definingUSE_MMAP_FILES
+andHAVE_MMAP
might work (if it works then report back to us). -Apache does its best to avoid copying bytes around in memory. The -first write of any request typically is turned into a
writev
+Apache does its best to avoid copying bytes around in memory. The +first write of any request typically is turned into a
writev
which combines both the headers and the first hunk of data: -When doing HTTP/1.1 chunked encoding Apache will generate up to four -element++writev(3, [{"HTTP/1.1 200 OK\r\nDate: Thu, 11"..., 245}, {"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 6144}], 2) = 6389 -writev
s. The goal is to push the byte copying +elementwritev
s. The goal is to push the byte copying into the kernel, where it typically has to happen anyhow (to assemble network packets). On testing, various Unixes (BSDI 2.x, Solaris 2.5, Linux 2.0.31+) properly combine the elements into network packets. Pre-2.0.31 Linux will not combine, and will create a packet for -each element, so upgrading is a good idea. DefiningNO_WRITEV
+each element, so upgrading is a good idea. DefiningNO_WRITEV
will disable this combining, but result in very poor chunked encoding performance. -The log write: +
The log write: -
-can be deferred by defining++write(17, "127.0.0.1 - - [10/Sep/1997:23:39"..., 71) = 71 -BUFFERED_LOGS
. In this case -up toPIPE_BUF
bytes (a POSIX defined constant) of log entries +can be deferred by definingBUFFERED_LOGS
. In this case +up toPIPE_BUF
bytes (a POSIX defined constant) of log entries are buffered before writing. At no time does it split a log entry -across aPIPE_BUF
boundary because those writes may not +across aPIPE_BUF
boundary because those writes may not be atomic. (i.e. entries from multiple children could become mixed together). The code does it best to flush this buffer when a child dies. -The lingering close code causes four system calls: +
The lingering close code causes four system calls: -
which were described earlier. -++shutdown(3, 1 /* send */) = 0 oldselect(4, [3], NULL, [3], {2, 0}) = 1 (in [3], left {2, 0}) read(3, "", 2048) = 0 close(3) = 0 -Let's apply some of these optimizations: -
-DSINGLE_LISTEN_UNSERIALIZED_ACCEPT -DBUFFERED_LOGS
and -Rule STATUS=no
. Here's the final trace: +Let's apply some of these optimizations: +
-DSINGLE_LISTEN_UNSERIALIZED_ACCEPT -DBUFFERED_LOGS
and +Rule STATUS=no
. Here's the final trace: -That's 19 system calls, of which 4 remain relatively easy to remove, but don't seem worth the effort.++accept(15, {sin_family=AF_INET, sin_port=htons(22286), sin_addr=inet_addr("127.0.0.1")}, [16]) = 3 sigaction(SIGUSR1, {SIG_IGN}, {0x8058c98, [], SA_INTERRUPT}) = 0 getsockname(3, {sin_family=AF_INET, sin_port=htons(8080), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0 @@ -775,15 +775,15 @@ read(3, "", 2048) = 0 close(3) = 0 sigaction(SIGUSR1, {0x8058c98, [], SA_INTERRUPT}, {SIG_IGN}) = 0 munmap(0x400e3000, 6144) = 0 -Appendix: The Pre-Forking Model
-Apache (on Unix) is a pre-forking model server. The -parent process is responsible only for forking child +
Apache (on Unix) is a pre-forking model server. The +parent process is responsible only for forking child processes, it does not serve any requests or service any network sockets. The child processes actually process connections, they serve multiple connections (one at a time) before dying. @@ -791,7 +791,7 @@ The parent spawns new or kills off old children in response to changes in the load on the server (it does so by monitoring a scoreboard which the children keep up to date). -
This model for servers offers a robustness that other models do +
This model for servers offers a robustness that other models do not. In particular, the parent code is very simple, and with a high degree of confidence the parent will continue to do its job without error. The children are complex, and when you add in third party @@ -800,22 +800,22 @@ corruption. Even should such a thing happen, it only affects one connection and the server continues serving requests. The parent quickly replaces the dead child. -
Pre-forking is also very portable across dialects of Unix. +
Pre-forking is also very portable across dialects of Unix. Historically this has been an important goal for Apache, and it continues to remain so. -
The pre-forking model comes under criticism for various +
The pre-forking model comes under criticism for various performance aspects. Of particular concern are the overhead of forking a process, the overhead of context switches between processes, and the memory overhead of having multiple processes. Furthermore it does not offer as many opportunities for data-caching -between requests (such as a pool of
mmapped
files). +between requests (such as a pool ofmmapped
files). Various other models exist and extensive analysis can be found in the - papers -of the JAWS project. In practice all of these costs vary drastically + papers +of the JAWS project. In practice all of these costs vary drastically depending on the operating system. -Apache's core code is already multithread aware, and Apache version +
Apache's core code is already multithread aware, and Apache version 1.3 is multithreaded on NT. There have been at least two other experimental implementations of threaded Apache (one using the 1.3 code base on DCE, and one using a custom user-level threads package and the 1.0 code base, @@ -824,5 +824,5 @@ of Apache will include abstractions of the server model so that we can continue to support the pre-forking model, and also support various threaded models. - - + + diff --git a/docs/manual/misc/security_tips.html b/docs/manual/misc/security_tips.html index 715ccb90d7..d454122ebc 100644 --- a/docs/manual/misc/security_tips.html +++ b/docs/manual/misc/security_tips.html @@ -15,51 +15,51 @@
Security Tips for Server Configuration
-
+
Some hints and tips on security issues in setting up a web server. Some of the suggestions will be general, others specific to Apache.
- -Permissions on ServerRoot Directories
+ +Permissions on ServerRoot Directories
In typical operation, Apache is started by the root -user, and it switches to the user defined by the User directive to serve hits. +user, and it switches to the user defined by the User directive to serve hits. As is the case with any command that root executes, you must take care that it is protected from modification by non-root users. Not only must the files themselves be writeable only by root, but so must the directories, and parents of all directories. For example, if you -choose to place ServerRoot in
/usr/local/apache
then it is +choose to place ServerRoot in/usr/local/apache
then it is suggested that you create that directory as root, with commands like these: -It is assumed that /, /usr, and /usr/local are only modifiable by root. When you install the httpd executable, you should ensure that it is similarly protected: -++mkdir /usr/local/apache cd /usr/local/apache mkdir bin conf logs chown 0 . bin conf logs chgrp 0 . bin conf logs chmod 755 . bin conf logs --++cp httpd /usr/local/apache/bin chown 0 /usr/local/apache/bin/httpd chgrp 0 /usr/local/apache/bin/httpd chmod 511 /usr/local/apache/bin/httpd -You can create an htdocs subdirectory which is modifiable by other +
You can create an htdocs subdirectory which is modifiable by other users -- since root never executes any files out of there, and shouldn't be creating files in there. -
If you allow non-root users to modify any files that root either +
If you allow non-root users to modify any files that root either executes or writes on then you open your system to root compromises. For example, someone could replace the httpd binary so that the next time you start it, it will execute some arbitrary code. If the logs @@ -73,16 +73,16 @@ may be able to overwrite the log itself with bogus data.
Server Side Includes
Server side includes (SSI) can be configured so that users can execute arbitrary programs on the server. That thought alone should send a shiver -down the spine of any sys-admin.
+down the spine of any sys-admin.
One solution is to disable that part of SSI. To do that you use the IncludesNOEXEC option to the Options -directive.
+directive.
Non Script Aliased CGI
-Allowing users to execute CGI scripts in any directory should only +
Allowing users to execute CGI scripts in any directory should only be considered if;
- You trust your users not to write scripts which will deliberately or @@ -90,23 +90,23 @@ accidentally expose your system to an attack.
- You consider security at your site to be so feeble in other areas, as to make one more potential hole irrelevant.
- You have no users, and nobody ever visits your server. -
+
Limiting CGI to special directories gives the admin control over +
Limiting CGI to special directories gives the admin control over what goes into those directories. This is inevitably more secure than -non script aliased CGI, but only if users with write access to the -directories are trusted or the admin is willing to test each new CGI +non script aliased CGI, but only if users with write access to the +directories are trusted or the admin is willing to test each new CGI script/program for potential security holes.
-Most sites choose this option over the non script aliased CGI approach.
+Most sites choose this option over the non script aliased CGI approach.
Always remember that you must trust the writers of the CGI script/programs or your ability to spot potential security holes in CGI, whether they were -deliberate or accidental.
+deliberate or accidental.
All the CGI scripts will run as the same user, so they have potential to conflict (accidentally or deliberately) with other scripts e.g. @@ -123,21 +123,21 @@ the Apache server code. Another popular way of doing this is with
To run a really tight ship, you'll want to stop users from setting
up .htaccess
files which can override security features
-you've configured. Here's one way to do it...
+you've configured. Here's one way to do it...
In the server configuration file, put -
-<Directory />
-AllowOverride None
-Options None
-allow from all
-</Directory>
-
+
+<Directory />
+AllowOverride None
+Options None
+allow from all
+</Directory>
+
Then setup for specific directoriesThis stops all overrides, Includes and accesses in all directories apart -from those named.
+from those named.
+
These configuration parameters control the core Apache features, and are always available.
AccessConfig conf/access.conf
+Syntax: AccessConfig filename
+Default: AccessConfig conf/access.conf
+Context: server config, virtual host
+Status: core
The server will read this file for more directives after reading the -ResourceConfig file. Filename is +ResourceConfig file. Filename is relative to the ServerRoot. This feature can be disabled using: -
AccessConfig /dev/null
+AccessConfig /dev/null
Historically, this file only contained
<Directory> sections; in fact it can now
-contain any server directive allowed in the server config context.
-AccessFileName .htaccess
+Syntax: AccessFileName filename filename ...
+Default: AccessFileName .htaccess
+Context: server config, virtual host
+Status: core
+Compatibility: AccessFileName can accept more than one filename only in Apache 1.3 and later
When returning a document to the client the server looks for the first existing access control file from this list of names in every directory of the path to the document, if access control files are enabled for that directory. For example: -
AccessFileName .acl
+AccessFileName .acl
before returning the document /usr/local/web/index.html, the
server will read /.acl, /usr/.acl, /usr/local/.acl and /usr/local/web/.acl
for directives, unless they have been disabled with
-
-<Directory />
-AllowOverride None
-</Directory>
+<Directory />
+AllowOverride None
+</Directory>
+Syntax: AddModule module module ...
+Context: server config
+Status: core
+Compatibility: AddModule is only available in Apache 1.2 and later
The server can have modules compiled in which are not actively in use. This directive can be used to enable the use of those modules. The server comes with a pre-loaded list of active modules; this list can be cleared with the ClearModuleList -directive.
AllowOverride All
+Syntax: AllowOverride override override ...
+Default: AllowOverride All
+Context: directory
+Status: core
When the server finds an .htaccess file (as specified by AccessFileName) it needs to know which -directives declared in that file can override earlier access information.
+directives declared in that file can override earlier access information.
-Override can be set to None
, in which case the server
-will not read the file, All
in which case the server will
+Override can be set to None
, in which case the server
+will not read the file, All
in which case the server will
allow all the directives, or one or more of the following:
-
+Syntax: AuthName auth-domain
+Context: directory, .htaccess
+Override: AuthConfig
+Status: core
This directive sets the name of the authorization realm for a directory. This realm is given to the client so that the user knows which username and @@ -210,81 +210,81 @@ password to send. It must be accompanied by AuthType and require directives, and directives such as AuthUserFile and -AuthGroupFile to work.
+Syntax: AuthType type
+Context: directory, .htaccess
+Override: AuthConfig
+Status: core
This directive selects the type of user authentication for a directory.
-Only Basic
is currently implemented.
+Only Basic
is currently implemented.
It must be accompanied by AuthName and
require directives, and directives such as
AuthUserFile and
-AuthGroupFile to work.
BindAddress *
+Syntax: BindAddress saddr
+Default: BindAddress *
+Context: server config
+Status: core
A Unix® http server can either listen for connections to every IP address of the server machine, or just one IP address of the server -machine. Saddr can be +machine. Saddr can be -
+ If the value is *, then the server will listen for connections on every IP address, otherwise it will only listen on the IP address -specified.+specified.
-Only one BindAddress
directive can be used. For more
+Only one BindAddress
directive can be used. For more
control over which address and ports Apache listens to, use the
-Listen
directive instead of
-BindAddress
.
+Listen
directive instead of
+BindAddress
.
-BindAddress
can be used as an alternative method for
+BindAddress
can be used as an alternative method for
supporting virtual hosts using
-multiple independent servers, instead of using <VirtualHost>
sections.
+multiple independent servers, instead of using <VirtualHost>
sections.
-
See Also:
-DNS Issues
-See Also:
-Setting which addresses and ports Apache uses
See Also:
+DNS Issues
+See Also:
+Setting which addresses and ports Apache uses
+Syntax: ClearModuleList
+Context: server config
+Status: core
+Compatibility: ClearModuleList is only available in Apache 1.2 and later
The server comes with a built-in list of active modules. This directive clears the list. It is assumed that the list will then be -re-populated using the AddModule directive.
ContentDigest off
-Compatibility: ContentDigest is only available in Apache 1.1 and later
-
-This directive enables the generation of Content-MD5
headers
+Syntax: ContentDigest on|off
+Default: ContentDigest off
+Context: server config, virtual host, directory, .htaccess
+Override: AuthConfig
+Status: experimental
+Compatibility: ContentDigest is only available in Apache 1.1 and later
+
+This directive enables the generation of Content-MD5
headers
as defined in RFC1864 respectively RFC2068.
MD5 is an algorithm for computing a "message digest" (sometimes called @@ -292,108 +292,108 @@ MD5 is an algorithm for computing a "message digest" (sometimes called that any alterations in the data will be reflected in alterations in the message digest.
-The Content-MD5
header provides an end-to-end message
+The Content-MD5
header provides an end-to-end message
integrity check (MIC) of the entity-body. A proxy or client may check this
header for detecting accidental modification of the entity-body
in transit.
Example header:
-
Content-MD5: AuLb7Dp1rqtRtxz2m9kRpA==
+
Content-MD5: AuLb7Dp1rqtRtxz2m9kRpA==
Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached).
-Content-MD5
is only sent for documents served by the
+Content-MD5
is only sent for documents served by the
core, and not by any module. For example, SSI documents, output from
CGI scripts, and byte range responses do not have this header.
-
+Syntax: CoreDumpDirectory directory
+Default: the same location as ServerRoot
+Context: server config
+Status: core
This controls the directory to which Apache attempts to switch before dumping core. The default is in the ServerRoot directory, however since this should not be writable by the user the server runs as, core dumps won't normally get written. If you want a core dump for debugging, you can use this directive to place -it in a different location.
DefaultType text/html
+Syntax: DefaultType mime-type
+Default: DefaultType text/html
+Context: server config, virtual host, directory, .htaccess
+Override: FileInfo
+Status: core
There will be times when the server is asked to provide a document -whose type cannot be determined by its MIME types mappings.
+whose type cannot be determined by its MIME types mappings.
The server must inform the client of the content-type of the document, so in
the event of an unknown type it uses the DefaultType
. For
example:
-
DefaultType image/gif
+DefaultType image/gif
would be appropriate for a directory which contained many gif images
-with filenames missing the .gif extension.
+Syntax: <Directory directory> ... </Directory>
+Context: server config, virtual host
+Status: Core.
<Directory> and </Directory> are used to enclose a group of directives which will apply only to the named directory and sub-directories of that directory. Any directive which is allowed in a directory -context may be used. Directory is either the full path to a directory, +context may be used. Directory is either the full path to a directory, or a wild-card string. In a wild-card string, `?' matches any single character, and `*' matches any sequences of characters. As of Apache 1.3, you may also use `[]' character ranges like in the shell. Also as of Apache 1.3 none of the wildcards match a `/' character, which more closely mimics the behaviour of Unix shells. Example: -
+-<Directory /usr/local/httpd/htdocs> Options Indexes FollowSymLinks </Directory> -+
Apache 1.2 and above: +
Apache 1.2 and above:
Extended regular expressions can also be used, with the addition of the
-~
character. For example:
~
character. For example:
-+would match directories in /www/ that consisted of three numbers. -<Directory ~ "^/www/.*/[0-9]{3}"> -+
If multiple (non-regular expression) directory sections match the +
If multiple (non-regular expression) directory sections match the directory (or its parents) containing a document, then the directives are applied in the order of shortest match first, interspersed with the directives from the .htaccess files. For example, with -
-<Directory />
-AllowOverride None
-</Directory>
-<Directory /home/*>
-AllowOverride FileInfo
-</Directory>
-for access to the document /home/web/dir/doc.html
the
+
+<Directory />
+AllowOverride None
+</Directory>
+<Directory /home/*>
+AllowOverride FileInfo
+</Directory>
+for access to the document /home/web/dir/doc.html
the
steps are:
-
+
Regular expression directory sections are handled slightly differently @@ -404,22 +404,22 @@ possible occurs. In Apache 1.3 regular expressions are not considered until after all of the normal sections have been applied. Then all of the regular expressions are tested in the order they appeared in the configuration file. For example, with -
-<Directory ~ abc$>
-... directives here ...
-</Directory>
-
+
+<Directory ~ abc$>
+... directives here ...
+</Directory>
+
Suppose that the filename being accessed is
-/home/abc/public_html/abc/index.html
. The server
-considers each of /
, /home
, /home/abc
,
-/home/abc/public_html
, and /home/abc/public_html/abc
+/home/abc/public_html/abc/index.html
. The server
+considers each of /
, /home
, /home/abc
,
+/home/abc/public_html
, and /home/abc/public_html/abc
in that order. In Apache 1.2, when
-/home/abc
is considered, the regular expression will match
+/home/abc
is considered, the regular expression will match
and be applied. In Apache 1.3 the regular expression isn't considered
at all at that point in the tree. It won't be considered until after
-all normal <Directory>s and .htaccess
files have
+all normal <Directory>s and .htaccess
files have
been applied. Then the regular expression will
-match on /home/abc/public_html/abc
and be applied.
+match on /home/abc/public_html/abc
and be applied.
@@ -449,72 +449,72 @@ page for more details. The directory sections typically occur in the access.conf file, but they may appear in any configuration file. <Directory> directives cannot nest, and cannot appear in a <Limit> section. -
+
-See also: How Directory, -Location and Files sections work for an explanation of how these +See also: How Directory, +Location and Files sections work for an explanation of how these different sections are combined when a request is received -
<DirectoryMatch> and </DirectoryMatch> are used to enclose a group of +
<DirectoryMatch> and </DirectoryMatch> are used to enclose a group of directives which will apply only to the named directory and sub-directories -of that directory, the same as <Directory>. However, it takes as an -argument a regular expression. For example:
+of that directory, the same as <Directory>. However, it takes as an +argument a regular expression. For example: -+-<DirectoryMatch "^/www/.*/[0-9]{3}"> -+
would match directories in /www/ that consisted of three numbers.
+would match directories in /www/ that consisted of three numbers.
-See Also: -<Directory> for a description of how +
See Also:
+<Directory> for a description of how
regular expressions are mixed in with normal <Directory>s.
-
-See also: How Directory,
-Location and Files sections work for an explanation of how these
+
+See also: How Directory,
+Location and Files sections work for an explanation of how these
different sections are combined when a request is received
-
DocumentRoot
-/usr/local/apache/htdocs
+Syntax: DocumentRoot directory-filename
+Default: DocumentRoot
+/usr/local/apache/htdocs
+Context: server config, virtual host
+Status: core
This directive sets the directory from which httpd will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document. Example: -
DocumentRoot /usr/web
-then an access to http://www.my.host.com/index.html
refers
-to /usr/web/index.html
.
+DocumentRoot /usr/web
+then an access to http://www.my.host.com/index.html
refers
+to /usr/web/index.html
.
There appears to be a bug in mod_dir which causes problems when the DocumentRoot has a trailing slash (i.e. "DocumentRoot /usr/web/") so please avoid that. -
+Syntax: ErrorDocument error-code document
+Context: server config, virtual host, directory, .htaccess
+Status: core
+Override: FileInfo
+Compatibility: The directory and .htaccess contexts
+are only available in Apache 1.1 and later.
In the event of a problem or error, Apache can be configured to do
one of four things,
@@ -530,19 +530,19 @@ one of four things,
using the ErrorDocument
directive, which is followed by
the HTTP response code and a message or URL.
-
Messages in this context begin with a single quote
-("
), which does not form part of the message itself.
+
Messages in this context begin with a single quote
+("
), which does not form part of the message itself.
Apache will sometimes offer additional information regarding the
problem/error.
URLs can begin with a slash (/) for local URLs, or be a full URL which the client can resolve. Examples: -
-ErrorDocument 500 http://foo.example.com/cgi-bin/tester
-ErrorDocument 404 /cgi-bin/bad_urls.pl
-ErrorDocument 401 /subscription_info.html
+
+ErrorDocument 500 http://foo.example.com/cgi-bin/tester
+ErrorDocument 404 /cgi-bin/bad_urls.pl
+ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today
-
+
Note that when you specify an ErrorDocument
that
points to a remote URL (ie. anything with a method such as "http" in
@@ -554,654 +554,654 @@ directive then it must refer to a local document. This results
from the nature of the HTTP basic authentication scheme.
See Also: documentation of customizable -responses.
ErrorLog logs/error_log
+Syntax: ErrorLog filename
+Default: ErrorLog logs/error_log
+Context: server config, virtual host
+Status: core
The error log directive sets the name of the file to which the server will log any errors it encounters. If the filename does not begin with a slash (/) then it is assumed to be relative to the ServerRoot. Example: -
ErrorLog /dev/null
-This effectively turns off error logging.+
ErrorLog /dev/null
+This effectively turns off error logging.SECURITY: See the security tips document for details on why your security could be compromised if the directory where logfiles are stored is writable by anyone other than the user that starts the server. -
- -
The <Files> directive provides for access control by
-filename. It is comparable to the <Directory> directive and
-<Location> directives. It
+Syntax: <Files filename>
+... </Files>
+Context: server config, virtual host, .htaccess
+Status: core
+Compatibility: only available in Apache
+1.2 and above.
+ +
The <Files> directive provides for access control by
+filename. It is comparable to the <Directory> directive and
+<Location> directives. It
should be matched with a </Files> directive. Directives that
apply to the filename given should be listed
-within. <Files>
sections are processed in the
+within. <Files>
sections are processed in the
order they appear in the configuration file, after the
-<Directory> sections and .htaccess
files are
-read, but before <Location> sections.
.htaccess
files are
+read, but before <Location> sections.
-The filename argument should include a filename, or a +
The filename argument should include a filename, or a
wild-card string, where `?' matches any single character, and `*' matches any
sequences of characters. Extended regular expressions can also be used,
with the addition of
-the ~
character. For example:
~
character. For example:
-+would match most common Internet graphics formats. In Apache 1.3 and -later, <FilesMatch> is preferred, +later, <FilesMatch> is preferred, however. -<Files ~ "\.(gif|jpe?g|png)$"> -+
Note that unlike <Directory>
and <Location>
sections,
-<Files>
sections can be used inside .htaccess
+
Note that unlike <Directory>
and <Location>
sections,
+<Files>
sections can be used inside .htaccess
files. This allows users to control access to their own files, at a
file-by-file level. When used in an .htaccess file, if the
-filename does not begin with a /
character,
+filename does not begin with a /
character,
the directory being applied will be prefixed automatically.
-
+
-See also: How Directory, -Location and Files sections work for an explanation of how these +See also: How Directory, +Location and Files sections work for an explanation of how these different sections are combined when a request is received -
- -
The <FilesMatch> directive provides for access control by -filename, just as the <Files> directive -does. However, it accepts a regular expression. For example:
- -+Syntax: <FilesMatch regex> +... </Files>-
+Context: server config, virtual host, .htaccess
+Status: core
+Compatibility: only available in Apache +1.3 and above.+ +
The <FilesMatch> directive provides for access control by +filename, just as the <Files> directive +does. However, it accepts a regular expression. For example:
+ +<FilesMatch "\.(gif|jpe?g|png)$"> -+
would match most common Internet graphics formats.
+would match most common Internet graphics formats.
-See also: How Directory, -Location and Files sections work for an explanation of how these +See also: How Directory, +Location and Files sections work for an explanation of how these different sections are combined when a request is received -Group #-1
+Syntax: Group unix-group
+Default: Group #-1
+Context: server config, virtual host
+Status: core
The Group directive sets the group under which the server will answer requests. In order to use this directive, the stand-alone server must be run initially -as root. Unix-group is one of: -
nobody
, but this is not always
-possible or desirable.
+server. Some admins use user nobody
, but this is not always
+possible or desirable.
Note: if you start the server as a non-root user, it will fail to change to the specified group, and will instead continue to run as the group of the -original user.
+original user.
Special note: Use of this directive in <VirtualHost> requires a properly configured suEXEC wrapper. When used inside a <VirtualHost> in this manner, only the group that CGIs are run as is affected. Non-CGI requests are still processed -as the group specified in the main Group directive.
+as the group specified in the main Group directive.
SECURITY: See User for a discussion of the security -considerations.
HostNameLookups off
double
available only in Apache
-1.3 and above.on
prior to Apache
-1.3.
+Syntax: HostNameLookups on | off | double
+Default: HostNameLookups off
+Context: server config, virtual host, directory, .htaccess
+Status: core
+Compatibility: double
available only in Apache
+1.3 and above.
+Compatibility: Default was on
prior to Apache
+1.3.
This directive enables DNS lookups so that host names can be logged (and
-passed to CGIs/SSIs in REMOTE_HOST
).
-The value double
refers to doing double-reverse DNS.
+passed to CGIs/SSIs in REMOTE_HOST
).
+The value double
refers to doing double-reverse DNS.
That is, after a reverse lookup is performed, a forward lookup is then
performed on that result. At least one of the ip addresses in the forward
lookup must match the original address. (In "tcpwrappers" terminology
-this is called PARANOID
.)
+this is called PARANOID
.)
-Regardless of the setting, when mod_access
+Regardless of the setting, when mod_access
is used for controlling access by hostname, a double reverse lookup
will be performed. This is necessary for security. Note that the
result of this double-reverse isn't generally available unless
-you set HostnameLookups double
. For example, if only
-HostnameLookups on
and a request is made to an object that
+you set HostnameLookups double
. For example, if only
+HostnameLookups on
and a request is made to an object that
is protected by hostname restrictions, regardless of whether the
double-reverse fails or not, CGIs will still be passed the single-reverse
-result in REMOTE_HOST
.
+result in REMOTE_HOST
.
-The default for this directive was previously on
in
-versions of Apache prior to 1.3. It was changed to off
+The default for this directive was previously on
in
+versions of Apache prior to 1.3. It was changed to off
in order to save the network traffic for those sites that don't truly
need the reverse lookups done. It is also better for the end users
because they don't have to suffer the extra latency that a lookup
entails.
-Heavily loaded sites should leave this directive off
, since DNS
-lookups can take considerable amounts of time. The utility logresolve,
-provided in the /support directory, can be used to look up host names
-from logged IP addresses offline.
off
, since DNS
+lookups can take considerable amounts of time. The utility logresolve,
+provided in the /support directory, can be used to look up host names
+from logged IP addresses offline.IdentityCheck off
+Syntax: IdentityCheck boolean
+Default: IdentityCheck off
+Context: server config, virtual host, directory, .htaccess
+Status: core
This directive enables RFC1413-compliant logging of the remote user name
for each connection, where the client machine runs identd or something similar.
-This information is logged in the access log. Boolean is either
-on
or off
.
+This information is logged in the access log. Boolean is either
+on
or off
.
The information should not be trusted in any way except for rudimentary usage -tracking.
+tracking.
Note that this can cause serious latency problems accessing your server since every request requires one of these lookups to be performed. When firewalls are involved each lookup might possibly fail and add 30 seconds of latency to each hit. So in general this is not very useful on public servers accessible from the Internet. -
-
+
-The <IfModule test>...</IfModule> +The <IfModule test>...</IfModule> section is used to mark directives that are conditional. The directives within an IfModule section are only -processed if the test is true. If test +processed if the test is true. If test is false, everything between the start and end markers -is ignored.
+is ignored.
-The test in the <IfModule> section directive +The test in the <IfModule> section directive can be one of two forms: -
In the former case, the directives between the start and end markers -are only processed if the module named module name is compiled +
In the former case, the directives between the start and end markers +are only processed if the module named module name is compiled in to Apache. The second format reverses the test, and only processes -the directives if module name is not compiled in. +the directives if module name is not compiled in. -
The module name argument is a module name as given as the file +
The module name argument is a module name as given as the file
name of the module, at the time it was compiled. For example,
-mod_rewrite.c
.
+mod_rewrite.c
.
-
<IfModule> sections are nest-able, which can be used to implement +
<IfModule> sections are nest-able, which can be used to implement simple multiple-module tests. -
This directive allows inclusion of other configuration files from within the server configuration files. -
KeepAlive 5
KeepAlive On
+
KeepAlive 5
KeepAlive On
This directive enables -Keep-Alive +Keep-Alive support. -
Apache 1.1: Set max-requests +
Apache 1.1: Set max-requests
to the maximum number of requests you want Apache to entertain per
request. A limit is imposed to prevent a client from hogging your
-server resources. Set this to 0
to disable support.
+server resources. Set this to 0
to disable support.
-
Apache 1.2 and later: Set to "On" to enable -persistent connections, "Off" to disable. See also the MaxKeepAliveRequests directive.
Apache 1.2 and later: Set to "On" to enable +persistent connections, "Off" to disable. See also the MaxKeepAliveRequests directive.
KeepAliveTimeout 15
+
KeepAliveTimeout 15
The number of seconds Apache will wait for a subsequent request before
closing the connection. Once a request has been received, the timeout
-value specified by the Timeout
directive
+value specified by the Timeout
directive
applies.
-
+Syntax:
+ <Limit method method ... > ... </Limit>
+Context: any
+Status: core
<Limit> and </Limit> are used to enclose a group of access control directives which will then apply only to the specified -access methods, where method is any valid HTTP method. +access methods, where method is any valid HTTP method. Any directive except another <Limit> or <Directory> may be used; the majority will be unaffected by the <Limit>. Example: -
-<Limit GET POST>
-require valid-user
-</Limit>
+
+<Limit GET POST>
+require valid-user
+</Limit>
If an access control directive appears outside a <Limit>
directive, then it applies to all access methods. The method names
listed can be one or more of: GET, POST, PUT, DELETE, CONNECT or
OPTIONS. If GET is used it will also restrict HEAD requests.
If you wish to limit all methods, do not include any
-<Limit> directive at all. - -
The Listen directive instructs Apache to listen to more than one IP
+Syntax:
+Listen [IP address:]port number
+Context: server config
+Status: core
+Compatibility: Listen is only available in Apache
+1.1 and later.
+ +
The Listen directive instructs Apache to listen to more than one IP
address or port; by default it responds to requests on all IP
-interfaces, but only on the port given by the Port
directive.
Port
directive.
-Listen can be used instead of BindAddress and Port. It tells
+Listen can be used instead of BindAddress and Port. It tells
the server to accept incoming requests on the specified port or
address-and-port combination. If the first format is used, with a port
number only, the server listens to the given port on all interfaces,
-instead of the port given by the Port directive. If an IP
+instead of the port given by the Port directive. If an IP
address is given as well as a port, the server will listen on the
-given port and interface. +given port and interface.
-Note that you may still require a Port directive so +Note that you may still require a Port directive so that URLs that Apache generates that point to your server still -work.
+work.
Multiple Listen directives may be used to specify a number of addresses and ports to listen to. The server will respond to requests from any of the listed addresses and ports. -
+
For example, to make the server accept connections on both port 80 and port 8000, use: -
+To make the server accept connections on two specified interfaces and port numbers, use -Listen 80 Listen 8000 -+
+-Listen 192.170.2.1:80 Listen 192.170.2.5:8000 -+
See Also:
-DNS Issues
-See Also:
-Setting which addresses and ports Apache uses
-See Also:
-Known Bugs
See Also:
+DNS Issues
+See Also:
+Setting which addresses and ports Apache uses
+See Also:
+Known Bugs
ListenBacklog 511
+Syntax: ListenBacklog backlog
+Default: ListenBacklog 511
+Context: server config
+Status: Core
+Compatibility: ListenBacklog is only available in Apache
+versions after 1.2.0.
The maximum length of the queue of pending connections. Generally no
tuning is needed or desired, however on some systems it is desirable
to increase this when under a TCP SYN flood attack. See
-the backlog parameter to the listen(2)
system call.
listen(2)
system call.
+Syntax: <Location URL>
+... </Location>
+Context: server config, virtual host
+Status: core
+Compatibility: Location is only available in Apache
+1.1 and later.
-
The <Location> directive provides for access control by -URL. It is comparable to the <Directory> directive, and +
The <Location> directive provides for access control by
+URL. It is comparable to the <Directory> directive, and
should be matched with a </Location> directive. Directives that
apply to the URL given should be listed
-within. <Location>
sections are processed in the
+within. <Location>
sections are processed in the
order they appear in the configuration file, after the
-<Directory> sections and .htaccess
files are
-read.
.htaccess
files are
+read.
-Note that, due to the way HTTP functions, URL prefix
-should, save for proxy requests, be of the form /path/
,
-and should not include the http://servername
. It doesn't
+
Note that, due to the way HTTP functions, URL prefix
+should, save for proxy requests, be of the form /path/
,
+and should not include the http://servername
. It doesn't
necessarily have to protect a directory (it can be an individual
file, or a number of files), and can include wild-cards. In a wild-card
string, `?' matches any single character, and `*' matches any
sequences of characters.
-
Apache 1.2 and above: +
Apache 1.2 and above:
Extended regular expressions can also be used, with the addition of
the
-~
character. For example:
~
character. For example:
-+-<Location ~ "/(extra|special)/data"> -+
would match URLs that contained the substring "/extra/data" or -"/special/data". However, in Apache 1.3 and above, use of <LocationMatch> is preferred.
+would match URLs that contained the substring "/extra/data" or +"/special/data". However, in Apache 1.3 and above, use of <LocationMatch> is preferred.
-The Location
functionality is especially useful when
-combined with the SetHandler
directive. For example, to enable status requests, but allow them only
+
The Location
functionality is especially useful when
+combined with the SetHandler
directive. For example, to enable status requests, but allow them only
from browsers at foo.com, you might use:
-
+-<Location /status> SetHandler server-status order deny,allow deny from all allow from .foo.com </Location> -+
-See also: How Directory, -Location and Files sections work for an explanation of how these +
+See also: How Directory, +Location and Files sections work for an explanation of how these different sections are combined when a request is received -
+Syntax: <LocationMatch regex>
+... </LocationMatch>
+Context: server config, virtual host
+Status: core
+Compatibility: Location is only available in Apache
+1.3 and later.
-
The <LocationMatch> directive provides for access control by -URL, in an identical manner to <Location>. However, it takes a regular -expression as an argument instead of a simple string. For example:
+The <LocationMatch> directive provides for access control by +URL, in an identical manner to <Location>. However, it takes a regular +expression as an argument instead of a simple string. For example:
-+-<LocationMatch "/(extra|special)/data"> -+
would match URLs that contained the substring "/extra/data" or -"/special/data".
+would match URLs that contained the substring "/extra/data" or +"/special/data".
-See also: How Directory, -Location and Files sections work for an explanation of how these +See also: How Directory, +Location and Files sections work for an explanation of how these different sections are combined when a request is received -LockFile logs/accept.lock
+Syntax: LockFile filename
+Default: LockFile logs/accept.lock
+Context: server config
+Status: core
The LockFile directive sets the path to the lockfile used when
Apache is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or
USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be
left at its default value. The main reason for changing it is if
-the logs
directory is NFS mounted, since the lockfile
-must be stored on a local disk. The PID of the main
-server process is automatically appended to the filename.
+the logs
directory is NFS mounted, since the lockfile
+must be stored on a local disk. The PID of the main
+server process is automatically appended to the filename.
SECURITY: It is best to avoid putting this file in a
world writable directory such as /var/tmp
because someone
could create a denial of service attack and prevent the server from
starting by creating a lockfile with the same name as the one the
-server will try to create.
+server will try to create.
MaxClients 256
+Syntax: MaxClients number
+Default: MaxClients 256
+Context: server config
+Status: core
The MaxClients directive sets the limit on the number of simultaneous requests that can be supported; not more than this number of child server -processes will be created.
MaxKeepAliveRequests 100
MaxKeepAliveRequests 100
The MaxKeepAliveRequests directive limits the number of requests
-allowed per connection when KeepAlive is
-on. If it is set to "0
", unlimited requests will be
+
The MaxKeepAliveRequests directive limits the number of requests
+allowed per connection when KeepAlive is
+on. If it is set to "0
", unlimited requests will be
allowed. We recommend that this setting be kept to a high value for
-maximum server performance.
MaxRequestsPerChild 0
+Syntax: MaxRequestsPerChild number
+Default: MaxRequestsPerChild 0
+Context: server config
+Status: core
The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die. If MaxRequestsPerChild is 0, then -the process will never expire.
+the process will never expire.
Setting MaxRequestsPerChild to a non-zero limit has two beneficial effects: -
MaxSpareServers 10
+Syntax: MaxSpareServers number
+Default: MaxSpareServers 10
+Context: server config
+Status: core
-The MaxSpareServers directive sets the desired maximum number of idle +The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent -process will kill off the excess processes.
+process will kill off the excess processes.
Tuning of this parameter should only be necessary on very busy sites. -Setting this parameter to a large number is almost always a bad idea.
+Setting this parameter to a large number is almost always a bad idea.
See also MinSpareServers and -StartServers.
MinSpareServers 5
+Syntax: MinSpareServers number
+Default: MinSpareServers 5
+Context: server config
+Status: core
-The MinSpareServers directive sets the desired minimum number of idle +The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer than MinSpareServers idle, then the parent -process creates new children at a maximum rate of 1 per second.
+process creates new children at a maximum rate of 1 per second.
Tuning of this parameter should only be necessary on very busy sites. -Setting this parameter to a large number is almost always a bad idea.
+Setting this parameter to a large number is almost always a bad idea.
See also MaxSpareServers and -StartServers.
-Compatibility: NameVirtualHost is only available in Apache 1.3 and later
+Syntax: NameVirtualHost addr[:port]
+Context: server config
+Status: core
+Compatibility: NameVirtualHost is only available in Apache 1.3 and later
The NameVirtualHost directive is a required directive if you want to configure -name-based virtual hosts.
-Although addr can be hostname it is recommended that you always use +Although addr can be hostname it is recommended that you always use an IP address, e.g. -
NameVirtualHost 111.22.33.44
+NameVirtualHost 111.22.33.44
With the NameVirtualHost directive the address to which your name-based
virtual host names resolve.
If you have multiple name-based hosts on multiple addresses,
-repeat the directive for each address.+repeat the directive for each address.
Optionally you can specify a port number on which the name-based virtual hosts should be used, e.g. -
NameVirtualHost 111.22.33.44:8080
+NameVirtualHost 111.22.33.44:8080
-See also:
-Apache Virtual Host documentation
+See also:
+Apache Virtual Host documentation
+Syntax: Options [+|-]option [+|-]option ...
+Context: server config, virtual host, directory, .htaccess
+Override: Options
+Status: core
The Options directive controls which server features are available in a particular directory. -
-option can be set to None
, in which case none of
+
+option can be set to None
, in which case none of
the extra features are enabled, or one or more of the following:
-
<Directory>
+Note: even though the server follows the symlink it does not
+change the pathname used to match against <Directory>
sections.
-Options
could apply to a directory,
+Normally, if multiple Options
could apply to a directory,
then the most specific one is taken complete; the options are not
-merged. However if all the options on the Options
+merged. However if all the options on the Options
directive are preceded by a + or - symbol, the options are
merged. Any options preceded by a + are added to the options
currently in force, and any options preceded by a - are removed from
@@ -1209,258 +1209,258 @@ the options currently in force. For example, without any + and - symbols: -
-<Directory /web/docs>
-Options Indexes FollowSymLinks
-</Directory>
-<Directory /web/docs/spec>
-Options Includes
+
+<Directory /web/docs>
+Options Indexes FollowSymLinks
+</Directory>
+<Directory /web/docs/spec>
+Options Includes
</Directory>
-
-then only Includes
will be set for the /web/docs/spec
-directory. However if the second Options
directive uses the +
-and - symbols:
-
-
-<Directory /web/docs>
-Options Indexes FollowSymLinks
-</Directory>
-<Directory /web/docs/spec>
-Options +Includes -Indexes
+
+then only Includes
will be set for the /web/docs/spec
+directory. However if the second Options
directive uses the +
+and - symbols:
+
+
+<Directory /web/docs>
+Options Indexes FollowSymLinks
+</Directory>
+<Directory /web/docs/spec>
+Options +Includes -Indexes
</Directory>
-
-then the options FollowSymLinks
and Includes
+
+then the options FollowSymLinks
and Includes
are set for the /web/docs/spec directory.
-PidFile logs/httpd.pid
+Syntax: PidFile filename
+Default: PidFile logs/httpd.pid
+Context: server config
+Status: core
The PidFile directive sets the file to which the server records the process id of the daemon. If the filename does not begin with a slash (/) then it is assumed to be relative to the ServerRoot. -The PidFile is only used in standalone mode.
+The PidFile is only used in standalone mode.
It is often useful to be able to send the server a signal, so that it closes and then reopens its ErrorLog and TransferLog, and re-reads its configuration files. This is done by sending a SIGHUP (kill -1) -signal to the process id listed in the PidFile.
+signal to the process id listed in the PidFile.
The PidFile is subject to the same warnings about log file placement and -security. +security. -
Port 80
+Syntax: Port number
+Default: Port 80
+Context: server config
+Status: core
-Number is a number from 0 to 65535; some port numbers (especially below
-1024) are reserved for particular protocols. See /etc/services
+Number is a number from 0 to 65535; some port numbers (especially below
+1024) are reserved for particular protocols. See /etc/services
for a list of some defined ports; the standard port for the http protocol
-is 80.
+is 80.
The Port directive has two behaviors, the first of which is necessary for NCSA backwards compatibility (and which is confusing in the context of -Apache).
+Apache).
-
:number
then Port has no effect on what address the server
+:number
then Port has no effect on what address the server
listens at.
-SERVER_PORT
environment variable (for
-CGI and SSI),
+SERVER_PORT
environment variable (for
+CGI and SSI),
and is used when the server must generate a URL that refers to itself
(for example when creating an external redirect to itself).
-+what ports a VirtualHost responds on, the +VirtualHost directive itself is used for that.
The primary behaviour of Port should be considered to be similar to that of -the ServerName directive. The ServerName -and Port together specify what you consider to be the canonical -address of the server.
+the ServerName directive. The ServerName +and Port together specify what you consider to be the canonical +address of the server.
Port 80 is one of Unix's special ports. All ports numbered below 1024 are reserved for system use, i.e. regular (non-root) users cannot make use of them; instead they can only use higher port numbers. To use port 80, you must start the server from the root account. After binding to the port and before accepting requests, Apache will change -to a low privileged user as set by the User directive.
+to a low privileged user as set by the User directive.
If you cannot use port 80, choose any other unused port. Non-root users -will have to choose a port number higher than 1023, such as 8000.
+will have to choose a port number higher than 1023, such as 8000.
SECURITY: if you do start the server as root, be sure not to set User to root. If you run the server as root whilst handling connections, your site may be open to a major security -attack.
+Syntax: require entity-name entity entity...
+Context: directory, .htaccess
+Override: AuthConfig
+Status: core
This directive selects which authenticated users can access a directory. The allowed syntaxes are: -
-Only the named users can access the directory.
-
-Only users in the named groups can access the directory.
-
+
+Only the named users can access the directory.
+
+Only users in the named groups can access the directory.
+
All valid users can access the directory. -
-If require
appears in a <Limit>
+
+If require
appears in a <Limit>
section, then it restricts access to the named methods, otherwise
it restricts access for all methods. Example:
-
-AuthType Basic
-AuthName somedomain
-AuthUserFile /web/users
-AuthGroupFile /web/groups
-<Limit GET POST>
-require group admin
+
+AuthType Basic
+AuthName somedomain
+AuthUserFile /web/users
+AuthGroupFile /web/groups
+<Limit GET POST>
+require group admin
</Limit>
-
+
Require must be accompanied by AuthName and
AuthType directives, and directives such as
AuthUserFile and
AuthGroupFile (to define users and
-groups) in order to work correctly.ResourceConfig conf/srm.conf
+Syntax: ResourceConfig filename
+Default: ResourceConfig conf/srm.conf
+Context: server config, virtual host
+Status: core
The server will read this file for more directives after reading the -httpd.conf file. Filename is relative to the +httpd.conf file. Filename is relative to the ServerRoot. This feature can be disabled using: -
ResourceConfig /dev/null
+ResourceConfig /dev/null
Historically, this file contained most directives except for server
configuration directives and <Directory>
sections; in fact it can now contain any server directive allowed in the
-server config context.+server config context.
-See also AccessConfig.
+Syntax: RLimitCPU # or 'max' [# or 'max']
+Default: Unset; uses operating system defaults
+Context: server config, virtual host
+Status: core
+Compatibility: RLimitCPU is only available in Apache 1.2 and later
Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter -can be a number, or max to indicate to the server that the limit should +can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial -startup phase.
+startup phase.
-CPU resource limits are expressed in seconds per process.
+CPU resource limits are expressed in seconds per process.
-See also RLimitMEM or RLimitNPROC.
+Syntax: RLimitMEM # or 'max' [# or 'max']
+Default: Unset; uses operating system defaults
+Context: server config, virtual host
+Status: core
+Compatibility: RLimitMEM is only available in Apache 1.2 and later
Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter -can be a number, or max to indicate to the server that the limit should +can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial -startup phase.
+startup phase.
-Memory resource limits are expressed in bytes per process.
+Memory resource limits are expressed in bytes per process.
-See also RLimitCPU or RLimitNPROC.
+Syntax: RLimitNPROC # or 'max' [# or 'max']
+Default: Unset; uses operating system defaults
+Context: server config, virtual host
+Status: core
+Compatibility: RLimitNPROC is only available in Apache 1.2 and later
Takes 1 or 2 parameters. The first parameter sets the soft resource limit for all processes and the second parameter sets the maximum resource limit. Either parameter -can be a number, or max to indicate to the server that the limit should +can be a number, or max to indicate to the server that the limit should be set to the maximum allowed by the operating system configuration. Raising the maximum resource limit requires that the server is running as root, or in the initial -startup phase.
+startup phase.
-Process limits control the number of processes per user.
+Process limits control the number of processes per user.
-Note: If CGI processes are not running under userids other than the +Note: If CGI processes are not running under userids other than the web server userid, this directive will limit the number of processes that the server itself can create. Evidence of this situation will be indicated by -cannot fork messages in the error_log.
+cannot fork messages in the error_log.
See also RLimitMEM or RLimitCPU. -
+Syntax: Satisfy 'any' or 'all'
+Default: Satisfy all
+Context: directory, .htaccess
+Status: core
+Compatibility: Satisfy is only available in Apache 1.2 and later
Access policy if both allow and require used. The parameter can be -either 'all' or 'any'. This directive is only useful +either 'all' or 'any'. This directive is only useful if access to a particular area is being restricted by both -username/password and client host address. In this case the +username/password and client host address. In this case the default behavior ("all") is to require that the client passes the -address access restriction and enters a valid username and +address access restriction and enters a valid username and password. With the "any" option the client will be granted access if they either pass the host restriction or enter a valid username and password. This can be used to password restrict an area, but to let clients from particular addresses in without prompting for a password. -
ScoreBoardFile logs/apache_status
+Syntax: ScoreBoardFile filename
+Default: ScoreBoardFile logs/apache_status
+Context: server config
+Status: core
The ScoreBoardFile directive is required on some architectures to place a file that the server will use to communicate between its children and @@ -1468,143 +1468,143 @@ the parent. The easiest way to find out if your architecture requires a scoreboard file is to run Apache and see if it creates the file named by the directive. If your architecture requires it then you must ensure that this file is not used at the same time by more than one invocation -of Apache.
+of Apache.
If you have to use a ScoreBoardFile then you may see improved speed by placing it on a RAM disk. But be careful that you heed the same warnings about log file placement and -security.
+security.
-Apache 1.2 and above:
+Apache 1.2 and above:
Linux 1.x users might be able to add
--DHAVE_SHMGET -DUSE_SHMGET_SCOREBOARD
to
-the EXTRA_CFLAGS
in your Configuration
. This
+-DHAVE_SHMGET -DUSE_SHMGET_SCOREBOARD
to
+the EXTRA_CFLAGS
in your Configuration
. This
might work with some 1.x installations, but won't work with all of
-them. (Prior to 1.3b4, HAVE_SHMGET
would have sufficed.)
+them. (Prior to 1.3b4, HAVE_SHMGET
would have sufficed.)
SVR4 users should consider adding
--DHAVE_SHMGET -DUSE_SHMGET_SCOREBOARD
to the
-EXTRA_CFLAGS
in your Configuration
. This
+-DHAVE_SHMGET -DUSE_SHMGET_SCOREBOARD
to the
+EXTRA_CFLAGS
in your Configuration
. This
is believed to work, but we were unable to test it in time for 1.2
-release. (Prior to 1.3b4, HAVE_SHMGET
would have sufficed.)
+release. (Prior to 1.3b4, HAVE_SHMGET
would have sufficed.)
-See Also: -Stopping and Restarting Apache
+See Also: +Stopping and Restarting Apache -
+Syntax: SendBufferSize bytes
+Context: server config
+Status: core
The server will set the TCP buffer size to the number of bytes specified. Very useful to increase past standard OS defaults on high speed high latency (i.e. 100ms or so, such as transcontinental fast pipes) -
+Syntax: ServerAdmin email-address
+Context: server config, virtual host
+Status: core
The ServerAdmin sets the e-mail address that the server includes in any -error messages it returns to the client.
+error messages it returns to the client.
It may be worth setting up a dedicated address for this, e.g. -
ServerAdmin www-admin@foo.bar.com
-as users do not always mention that they are talking about the server!ServerAdmin www-admin@foo.bar.com
+as users do not always mention that they are talking about the server!
+Syntax: ServerAlias host1 host2 ...
+Context: virtual host
+Status: core
+Compatibility: ServerAlias is only available in Apache
+1.1 and later.
The ServerAlias directive sets the alternate names for a host, for use with -name-based virtual hosts. +name-based virtual hosts. -
See also: -Apache Virtual Host documentation +
See also: +Apache Virtual Host documentation -
+Syntax: ServerName fully-qualified domain name
+Context: server config, virtual host
+Status: core
The ServerName directive sets the hostname of the server; this is only used when creating redirection URLs. If it is not specified, then the server attempts to deduce it from its own IP address; however this may not work reliably, or may not return the preferred hostname. For example: -
ServerName www.wibble.com
+ServerName www.wibble.com
would be used if the canonical (main) name of the actual machine
-were monster.wibble.com
.-
See Also: -DNS Issues
-monster.wibble.com
.+
See Also: +DNS Issues
+
+Syntax: ServerPath pathname
+Context: virtual host
+Status: core
+Compatibility: ServerPath is only available in Apache
+1.1 and later.
The ServerPath directive sets the legacy URL pathname for a host, for -use with name-based virtual hosts. +use with name-based virtual hosts. -
See also: -Apache Virtual Host documentation +
See also: +Apache Virtual Host documentation -
ServerRoot /usr/local/apache
+Syntax: ServerRoot directory-filename
+Default: ServerRoot /usr/local/apache
+Context: server config
+Status: core
The ServerRoot directive sets the directory in which the server lives.
-Typically it will contain the subdirectories conf/
and
-logs/
. Relative paths for other configuration files are taken
-as relative to this directory.
+Typically it will contain the subdirectories conf/
and
+logs/
. Relative paths for other configuration files are taken
+as relative to this directory.
-See also the -d
option to httpd.
-See also the security tips -for information on how to properly set permissions on the ServerRoot.
+See also the -d
option to httpd.
+See also the security tips +for information on how to properly set permissions on the ServerRoot.
-
ServerType standalone
+Syntax: ServerType type
+Default: ServerType standalone
+Context: server config
+Status: core
The ServerType directive sets how the server is executed by the system. -Type is one of -
/etc/inetd.conf
-/etc/rc.local
or
-/etc/rc3.d/...
.)
-/etc/inetd.conf
+/etc/rc.local
or
+/etc/rc3.d/...
.)
++
Standalone is the most common setting for ServerType since it is far more efficient. The server is started once, and services all subsequent connections. If you intend running Apache to serve a busy site, -standalone will probably be your only option.
+standalone will probably be your only option.
StartServers 5
+Syntax: StartServers number
+Default: StartServers 5
+Context: server config
+Status: core
The StartServers directive sets the number of child server processes created on startup. As the number of processes is dynamically controlled depending -on the load, there is usually little reason to adjust this parameter.
+on the load, there is usually little reason to adjust this parameter.
-
When running with Microsoft Windows, this directive sets the total +
When running with Microsoft Windows, this directive sets the total number of child processes running. Since the Windows version of Apache is multithreaded, one processes handles all the requests. The rest are held in reserve until the main processes dies. See also MinSpareServers and -MaxSpareServers.
ThreadsPerChild 50
ThreadsPerChild 50
This directive tells the server how many threads it should use. This +
This directive tells the server how many threads it should use. This is the maximum number of connections the server can handle at once; be sure and set this number high enough for your site if you get a lot of hits. -
See also StartServers and MaxRequestsPerChild.
+See also StartServers and MaxRequestsPerChild.
-TimeOut 300
+Syntax: TimeOut number
+Default: TimeOut 300
+Context: server config
+Status: core
The TimeOut directive currently defines the amount of time Apache will wait for three things: @@ -1681,121 +1681,121 @@ situations. It is not set any lower by default because there may still be odd places in the code where the timer is not reset when a packet is sent. -
User #-1
+Syntax: User unix-userid
+Default: User #-1
+Context: server config, virtual host
+Status: core
The User directive sets the userid as which the server will answer requests. In order to use this directive, the standalone server must be run initially -as root. Unix-userid is one of: -
nobody
, but this is not always possible or desirable.
+nobody
, but this is not always possible or desirable.
Notes: If you start the server as a non-root user, it will fail to change to the lesser privileged user, and will instead continue to run as that original user. If you do start the server as root, then it is normal -for the parent process to remain running as root.
+for the parent process to remain running as root.
Special note: Use of this directive in <VirtualHost> requires a properly configured suEXEC wrapper. When used inside a <VirtualHost> in this manner, only the user that CGIs are run as is affected. Non-CGI requests are still processed -with the user specified in the main User directive.
+with the user specified in the main User directive.
SECURITY: Don't set User (or Group) to
-root
unless you know exactly what you are doing, and what the
-dangers are.
root
unless you know exactly what you are doing, and what the
+dangers are.
+Syntax: <VirtualHost addr[:port] ...> ...
+</VirtualHost>
+Context: server config
+Status: Core.
+Compatibility: Non-IP address-based Virtual Hosting only
+available in Apache 1.1 and later.
+Compatibility: Multiple address support only available in
+Apache 1.2 and later.
<VirtualHost> and </VirtualHost> are used to enclose a group of directives which will apply only to a particular virtual host. Any directive which is allowed in a virtual host context may be used. When the server receives a request for a document on a particular virtual host, it uses the configuration directives enclosed in the <VirtualHost> -section. Addr can be -
Example: -
-
-<VirtualHost 10.1.2.3>
-ServerAdmin webmaster@host.foo.com
-DocumentRoot /www/docs/host.foo.com
-ServerName host.foo.com
-ErrorLog logs/host.foo.com-error_log
-TransferLog logs/host.foo.com-access_log
+section. Addr can be
+ Example:
+
+
+<VirtualHost 10.1.2.3>
+ServerAdmin webmaster@host.foo.com
+DocumentRoot /www/docs/host.foo.com
+ServerName host.foo.com
+ErrorLog logs/host.foo.com-error_log
+TransferLog logs/host.foo.com-access_log
</VirtualHost>
-
+
Each VirtualHost must correspond to a different IP address, different port number or a
different host name for the server, in the latter case the server
machine must be configured to accept IP packets for multiple
addresses. (If the machine does not have multiple network interfaces,
-then this can be accomplished with the ifconfig alias
+then this can be accomplished with the ifconfig alias
command (if your OS supports it), or with kernel patches like VIF (for SunOS(TM) 4.1.x)).+HREF="../misc/vif-info.html">VIF (for SunOS(TM) 4.1.x)).
-The special name _default_
can be specified in which case
+The special name _default_
can be specified in which case
this virtual host will match any IP address that is not explicitly listed
in another virtual host. In the absence of any _default_ virtual host
the "main" server config, consisting of all those definitions outside
-any VirtualHost section, is used when no match occurs.
+any VirtualHost section, is used when no match occurs.
-You can specify a :port
to change the port that is matched.
+You can specify a :port
to change the port that is matched.
If unspecified then it defaults to the same port as the most recent
-Port
statement of the main server. You
-may also specify :*
to match all ports on that address.
-(This is recommended when used with _default_
.)
+Port
statement of the main server. You
+may also specify :*
to match all ports on that address.
+(This is recommended when used with _default_
.)
-SECURITY: See the +SECURITY: See the security tips document for details on why your security could be compromised if the directory where logfiles are stored is writable by anyone other than the user that starts the server. -
NOTE: The use of <VirtualHost> does -not affect what addresses Apache listens on. You may +
NOTE: The use of <VirtualHost> does +not affect what addresses Apache listens on. You may need to ensure that Apache is listening on the correct addresses using -either BindAddress or Listen. - -
See also:
-Apache Virtual Host documentation
-See also:
-Warnings about DNS and Apache
-See also:
-Setting which addresses and ports Apache uses
-See also: How Directory,
-Location and Files sections work for an explanation of how these
+either BindAddress or Listen.
+
+
See also:
+Apache Virtual Host documentation
+See also:
+Warnings about DNS and Apache
+See also:
+Setting which addresses and ports Apache uses
+See also: How Directory,
+Location and Files sections work for an explanation of how these
different sections are combined when a request is received
-
Below is a list of all of the modules that come as part of the @@ -23,93 +23,93 @@ Apache distribution. See also the complete alphabetical list of >all Apache directives.
-
-This module is contained in the mod_access.c
file, and
+This module is contained in the mod_access.c
file, and
is compiled in by default. It provides access control based on client
hostname or IP address.
-Syntax: allow from host host ...
-Context: directory, .htaccess
-Override: Limit
-Status: Base
-Module: mod_access
-
The allow directive affects which hosts can access a given directory. -Host is one of the following: -
-all
-all
+Example:
-allow from .ncsa.uiuc.edu
+allow from .ncsa.uiuc.edu
All hosts in the specified domain are allowed access. -
+
-Note that this compares whole components; bar.edu
-would not match foobar.edu
.
+Note that this compares whole components; bar.edu
+would not match foobar.edu
.
See also deny, order, and -BrowserMatch. -
+BrowserMatch. +
-Syntax: allow from env=variablename
-Context: directory, .htaccess
-Override: Limit
-Status: Base
-Module: mod_access
-Compatibility: Apache 1.2 and above
-
The allow from env directive controls access to a directory by the existence (or non-existence) of an environment variable. @@ -91,74 +91,74 @@ existence (or non-existence) of an environment variable.
Example:
-+In this case browsers with the user-agent string KnockKnock/2.0 will be allowed access, and all others will be denied.+-In this case browsers with the user-agent string KnockKnock/2.0 will +BrowserMatch ^KnockKnock/2.0 let_me_in <Directory /docroot> order deny,allow deny from all allow from env=let_me_in </Directory> -
See also deny from env and order. -
-
-Syntax: deny from host host ...
-Context: directory, .htaccess
-Override: Limit
-Status: Base
-Module: mod_access
-
The deny directive affects which hosts can access a given directory. -Host is one of the following: -
-all
-all
+Example:
-deny from 16
+deny from 16
All hosts in the specified network are denied access. -
+
-Note that this compares whole components; bar.edu
-would not match foobar.edu
.
-
bar.edu
+would not match foobar.edu
.
+
+
-Syntax: deny from env=variablename
-Context: directory, .htaccess
-Override: Limit
-Status: Base
-Module: mod_access
-Compatibility: Apache 1.2 and above
-
The deny from env directive controls access to a directory by the existence (or non-existence) of an environment variable. @@ -166,61 +166,61 @@ existence (or non-existence) of an environment variable.
Example:
-+In this case browsers with the user-agent string BadRobot/0.9 will be denied access, and all others will be allowed.+-In this case browsers with the user-agent string BadRobot/0.9 will +BrowserMatch ^BadRobot/0.9 go_away <Directory /docroot> order allow,deny allow from all deny from env=go_away </Directory> -
See also allow from env and order. -
-
-Syntax: order ordering
-Default: order deny,allow
-Context: directory, .htaccess
-Override: Limit
-Status: Base
-Module: mod_access
-
order deny,allow
The order directive controls the order in which allow and -deny directives are evaluated. Ordering is one +deny directives are evaluated. Ordering is one of
-
-Note that in all cases every allow
and deny
-statement is evaluated, there is no "short-circuiting".
+Note that in all cases every allow
and deny
+statement is evaluated, there is no "short-circuiting".
+
Example:
-
- order deny,allow
- deny from all
- allow from .ncsa.uiuc.edu
-
+
+ order deny,allow
+ deny from all
+ allow from .ncsa.uiuc.edu
+
Hosts in the ncsa.uiuc.edu domain are allowed access; all other hosts are denied access. diff --git a/docs/manual/mod/mod_actions.html b/docs/manual/mod/mod_actions.html index 07823cbc82..dd41533dad 100644 --- a/docs/manual/mod/mod_actions.html +++ b/docs/manual/mod/mod_actions.html @@ -13,9 +13,9 @@ ALINK="#FF0000" > -
-This module is contained in the mod_actions.c
file, and
+This module is contained in the mod_actions.c
file, and
is compiled in by default. It provides for
executing CGI scripts based on media type or request method. It is not
present in versions prior to Apache 1.1.
@@ -27,64 +27,64 @@ is requested. This makes it much easier to execute scripts that
process files.
-Syntax: Action mime-type cgi-script
-Context: server config, virtual host, directory, .htaccess
-Override: FileInfo
-Status: Base
-Module: mod_actions
-Compatibility: Action is only available in Apache 1.1
+Syntax: Action mime-type cgi-script
+Context: server config, virtual host, directory, .htaccess
+Override: FileInfo
+Status: Base
+Module: mod_actions
+Compatibility: Action is only available in Apache 1.1
and later
-
-This directive adds an action, which will activate cgi-script when -a file of content type mime-type is requested. It sends the +This directive adds an action, which will activate cgi-script when +a file of content type mime-type is requested. It sends the URL and file path of the requested document using the standard CGI PATH_INFO and PATH_TRANSLATED environment variables.
-
-Syntax: Script method cgi-script
-Context: server config, virtual host, directory
-Status: Base
-Module: mod_actions
-Compatibility: Script is only available in Apache 1.1
+Syntax: Script method cgi-script
+Context: server config, virtual host, directory
+Status: Base
+Module: mod_actions
+Compatibility: Script is only available in Apache 1.1
and later
-
-This directive adds an action, which will activate cgi-script when
-a file is requested using the method of method, which can be
-one of GET
, POST
, PUT
or
-DELETE
. It sends the
+
+This directive adds an action, which will activate cgi-script when
+a file is requested using the method of method, which can be
+one of GET
, POST
, PUT
or
+DELETE
. It sends the
URL and file path of the requested document using the standard
CGI PATH_INFO and PATH_TRANSLATED environment variables.
+
Note that the Script command defines default actions only. If a CGI
script is called, or some other resource that is capable of handling
the requested method internally, it will do so. Also note that Script
-with a method of GET
will only be called if there are
+with a method of GET
will only be called if there are
query arguments present (e.g. foo.html?hi). Otherwise, the request
will proceed normally.
+
Examples:
-+Script GET /cgi-bin/search #e.g. for <ISINDEX>-style searching Script PUT /~bob/put.cgi -+