Commit be4539f5 authored by No Author's avatar No Author
Browse files

This commit was manufactured by cvs2svn to create branch 'APACHE_1_2_X'.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_1_2_X@78271 13f79535-47bb-0310-9956-ffa450edef68
parent 1f599711
Loading
Loading
Loading
Loading

docs/docroot/apache_pb.gif

deleted100644 → 0
−2.27 KiB
Loading image diff...

docs/manual/bind.html.en

deleted100644 → 0
+0 −109
Original line number Diff line number Diff line
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<title>Setting which addresses and ports Apache uses</title>
</head>

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
 BGCOLOR="#FFFFFF"
 TEXT="#000000"
 LINK="#0000FF"
 VLINK="#000080"
 ALINK="#FF0000"
>
<!--#include virtual="header.html" -->
<h1 ALIGN="CENTER">Setting which addresses and ports Apache uses</h1>

<hr>

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 <tt>Port</tt> 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.<p>

There are two directives used to restrict or specify which addresses
and ports Apache listens to.

<ul>
<li><a href="#bindaddress">BindAddress</a> is used to restrict the server to listening to
  a single address, and can be used to permit multiple Apache servers
  on the same machine listening to different IP addresses.
<li><a href="#listen">Listen</a> can be used to make a single Apache server listen
  to more than one address and/or port.
</ul>

<h3><a name="bindaddress">BindAddress</a></h3>
<strong>Syntax:</strong> BindAddress <em>[ * | IP-address | hostname ]</em><br>
<strong>Default:</strong> <code>BindAddress *</code><br>
<strong>Context:</strong> server config<br>
<strong>Status:</strong> Core<p>

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 <tt>Port</tt> directive. Only one BindAddress
should be used.

<h3><a name="listen">Listen</a></h3>
<strong>Syntax:</strong> Listen <em>[ port | IP-address:port ]</em><br>
<strong>Default:</strong> <code>none</code><br>
<strong>Context:</strong> server config<br>
<strong>Status:</strong> Core<p>

<tt>Listen</tt> can be used instead of <tt>BindAddress</tt> and
<tt>Port</tt>. 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 <tt>Port</tt>
directive. If an IP address is given as well as a port, the server
will listen on the given port and interface.  <p> 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.<p>

For example, to make the server accept connections on both port
80 and port 8000, use:
<pre>
   Listen 80
   Listen 8000
</pre>

To make the server accept connections on two specified
interfaces and port numbers, use
<pre>
   Listen 192.170.2.1:80
   Listen 192.170.2.5:8000
</pre>

<h2>How this works with Virtual Hosts</h2>

BindAddress and Listen do not implement Virtual Hosts. They tell the
main server what addresses and ports to listen to.  If no
&lt;VirtualHost&gt; directives are used, the server will behave the
same for all accepted requests. However, &lt;VirtualHost&gt; can be
used to specify a different behavior for one or more of the addresses
and ports. To implement a VirtualHost, the server must first be told
to listen to the address and port to be used. Then a
&lt;VirtualHost&gt; section should be created for a specified address
and port to set the behavior of this virtual host. Note that if the
&lt;VirtualHost&gt; is set for an address and port that the server is
not listening to, it cannot be accessed.

<h2>See also</h2>

See also the documentation on
<a href="virtual-host.html">Virtual Hosts</a>,
<a href="host.html">Non-IP virtual hosts</a>,
<a href="mod/core.html#bindaddress">BindAddress directive</a>,
<a href="mod/core.html#port">Port directive</a>,
<a href="dns-caveats.html">DNS Issues</a>
and
<a href="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</a>.

<!--#include virtual="footer.html" -->
</BODY>
</HTML>

docs/manual/cgi_path.html.en

deleted100644 → 0
+0 −93
Original line number Diff line number Diff line
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<title>PATH_INFO Changes in the CGI Environment</title>
</head>

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
 BGCOLOR="#FFFFFF"
 TEXT="#000000"
 LINK="#0000FF"
 VLINK="#000080"
 ALINK="#FF0000"
>
<!--#include virtual="header.html" -->
<h1 ALIGN="CENTER">PATH_INFO Changes in the CGI Environment</h1>

<hr>

<h2><a name="over">Overview</a></h2>

<p>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 (<a
href="#compat">see below</a>).

<h2><a name="prob">The Problem</a></h2>

<p>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:
<pre>
     Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph
</pre>
<p>In this case, <code>user.cgi</code> 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 "<code>/cgi-ralph/script/</code>", the
code would set PATH_INFO to "<code>/ralph/script</code>", and
SCRIPT_NAME to "<code>/cgi-</code>". Obviously, the latter is
incorrect. In certain cases, this could even cause the server to
crash.</p>

<h2><a name="solution">The Solution</a></h2>

<p>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 "<code>/script</code>", and
SCRIPT_NAME to "<code>/cgi-ralph</code>". This makes sense and results
in no server behavior problems. It also permits the script to be
guaranteed that
"<code>http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO</code>"
will always be an accessible URL that points to the current script,
something which was not necessarily true with previous versions of
Apache.

<p>However, the "<code>/ralph</code>"
information from the <code>Alias</code> 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 href="#compat">a workaround.</a>

<h2><a name="compat">Compatibility with Previous Servers</a></h2>

<p>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.</p>

<p>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:
<pre>
    $path_info = $ENV{'FILEPATH_INFO'} || $ENV{'PATH_INFO'};
</pre>

<p>By doing this, a script can work with all servers supporting the
CGI/1.1 specification, including all versions of Apache.</p>

<!--#include virtual="footer.html" -->
</BODY>
</HTML>
+0 −426
Original line number Diff line number Diff line
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Apache Content Negotiation</TITLE>
</HEAD>

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
 BGCOLOR="#FFFFFF"
 TEXT="#000000"
 LINK="#0000FF"
 VLINK="#000080"
 ALINK="#FF0000"
>
<!--#include virtual="header.html" -->
<h1 ALIGN="CENTER">Content Negotiation</h1>

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.  <p>

Content negotiation is provided by the 
<a href="mod/mod_negotiation.html">mod_negotiation</a> module,
which is compiled in by default.

<hr>

<h2>About Content Negotiation</h2>

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
appropriate choice is to give the user an index page, and let them
select. However it is often possible for the server to choose
automatically. This works because browsers can send as part of each
request information about what representations they prefer. For
example, a browser could indicate that it would like to see
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

<pre>
  Accept-Language: fr
</pre>

Note that this preference will only be applied when there is a choice
of representations and they vary by language. 
<p>

As an example of a more complex request, this browser has been
configured to accept French and English, but prefer French, and to
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:

<pre>
  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
</pre>

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.
<p>

The terms used in content negotiation are: a <b>resource</b> 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 <b>representations</b>
or <b>variants</b>. The ways in which the variants for a particular
resource vary are called the <b>dimensions</b> of negotiation.

<h2>Negotiation in Apache</h2>

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: 

<ul>
  <li> Using a type map (i.e., a <code>*.var</code> file) which
       names the files containing the variants explicitly
  <li> Or using a 'MultiViews' search, where the server does an implicit 
       filename pattern match, and chooses from among the results.
</ul>

<h3>Using a type-map file</h3>

A type map is a document which is associated with the handler
named <code>type-map</code> (or, for backwards-compatibility with
older Apache configurations, the mime type
<code>application/x-type-map</code>).  Note that to use this feature,
you've got to have a <code>SetHandler</code> some place which defines a
file suffix as <code>type-map</code>; this is best done with a
<pre>

  AddHandler type-map var

</pre>
in <code>srm.conf</code>.  See comments in the sample config files for
details. <p>

Type map files have an entry for each available variant; these entries
consist of contiguous RFC822-format header lines.  Entries for
different variants are separated by blank lines.  Blank lines are
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:
<pre>

  URI: foo

  URI: foo.en.html
  Content-type: text/html
  Content-language: en

  URI: foo.fr.de.html
  Content-type: text/html; charset=iso-8859-2
  Content-language: fr, de
</pre>

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):
<pre>
  URI: foo

  URI: foo.jpeg
  Content-type: image/jpeg; qs=0.8

  URI: foo.gif
  Content-type: image/gif; qs=0.5

  URI: foo.txt
  Content-type: text/plain; qs=0.01

</pre>
<p>

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.  <p>

The full list of headers recognized is:

<dl>
  <dt> <code>URI:</code>
  <dd> uri of the file containing the variant (of the given media
       type, encoded with the given content encoding).  These are
       interpreted as URLs relative to the map file; they must be on
       the same server (!), and they must refer to files to which the
       client would be granted access if they were to be requested
       directly. 
  <dt> <code>Content-type:</code>
  <dd> media type --- charset, level and "qs" parameters may be given.  These
       are often referred to as MIME types; typical media types are
       <code>image/gif</code>, <code>text/plain</code>, or
       <code>text/html;&nbsp;level=3</code>.
  <dt> <code>Content-language:</code>
  <dd> The languages of the variant, specified as an Internet standard
       language code (e.g., <code>en</code> for English,
       <code>kr</code> for Korean, etc.).
  <dt> <code>Content-encoding:</code>
  <dd> If the file is compressed, or otherwise encoded, rather than
       containing the actual raw data, this says how that was done.
       For compressed files (the only case where this generally comes
       up), content encoding should be
       <code>x-compress</code>, or <code>x-gzip</code>, as appropriate.
  <dt> <code>Content-length:</code>
  <dd> The size of the file.  Clients can ask to receive a given media
       type only if the variant isn't too big; specifying a content
       length in the map allows the server to compare against these
       thresholds without checking the actual file.
</dl>

<h3>Multiviews</h3>

This is a per-directory option, meaning it can be set with an
<code>Options</code> directive within a <code>&lt;Directory&gt;</code>,
<code>&lt;Location&gt;</code> or <code>&lt;Files&gt;</code>
section in <code>access.conf</code>, or (if <code>AllowOverride</code>
is properly set) in <code>.htaccess</code> files.  Note that
<code>Options All</code> does not set <code>MultiViews</code>; you
have to ask for it by name.  (Fixing this is a one-line change to
<code>http_core.h</code>).

<p>

The effect of <code>MultiViews</code> is as follows: if the server
receives a request for <code>/some/dir/foo</code>, if
<code>/some/dir</code> has <code>MultiViews</code> enabled, and
<code>/some/dir/foo</code> does <em>not</em> 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.

<p>

This applies to searches for the file named by the
<code>DirectoryIndex</code> directive, if the server is trying to
index a directory; if the configuration files specify
<pre>

  DirectoryIndex index

</pre> then the server will arbitrate between <code>index.html</code>
and <code>index.html3</code> if both are present.  If neither are
present, and <code>index.cgi</code> is there, the server will run it.

<p>

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
special treatment --- if the request was a POST, or a GET with
QUERY_ARGS or PATH_INFO, the script is given an extremely high quality
rating, and generally invoked; otherwise it is given an extremely low
quality rating, which generally causes one of the other views (if any)
to be retrieved.

<h2>The Negotiation Algorithm</h2>

After Apache has obtained a list of the variants for a given resource,
either from a type-map file or from the filenames in the directory, it
applies a algorithm to decide on the 'best' variant to return, if
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.  <p>

In some circumstances, Apache can 'fiddle' the quality factor of a
particular dimension to achieve a better result. The ways Apache can
fiddle quality factors is explained in more detail below.

<h3>Dimensions of Negotiation</h3>

<table>
<tr><th>Dimension
<th>Notes
<tr><td>Media Type
<td>Browser indicates preferences on Accept: header. Each item 
can have an associated quality factor. Variant description can also
have a quality factor.
<tr><td>Language
<td>Browser indicates preferences on Accept-Language: header. Each
item
can have a quality factor. Variants can be associated with none, one
or more languages.
<tr><td>Encoding
<td>Browser indicates preference with Accept-Encoding: header.
<tr><td>Charset
<td>Browser indicates preference with Accept-Charset: header. Variants
can indicate a charset as a parameter of the media type.
</table>

<h3>Apache Negotiation Algorithm</h3>

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:
<p>

<ol>
<li>
Firstly, for each dimension of the negotiation, the appropriate
Accept header is checked and a quality assigned to this each
variant. If the Accept header for any dimension means that this
variant is not acceptable, eliminate it. If no variants remain, go
to step 4.

<li>Select the 'best' variant by a process of elimination. Each of
the following tests is applied in order. Any variants not selected at
each stage are eliminated. After each test, if only one variant
remains, it is selected as the best match. If more than one variant
remains, move onto the next test.

<ol>
<li>Multiply the quality factor from the Accept header with the
  quality-of-source factor for this variant's media type, and select
  the variants with the highest value

<li>Select the variants with the highest language quality factor

<li>Select the variants with the best language match, using either the
  order of languages on the <code>LanguagePriority</code> directive (if present),
  else the order of languages on the Accept-Language header.

<li>Select the variants with the highest 'level' media parameter
  (used to give the version of text/html media types). 

<li>Select only unencoded variants, if there is a mix of encoded
  and non-encoded variants. If either all variants are encoded
  or all variants are not encoded, select all.

<li>Select only variants with acceptable charset media parameters,
  as given on the Accept-Charset header line. Charset ISO-8859-1
  is always acceptable. Variants not associated with a particular
  charset are assumed to be in ISO-8859-1.

<li>Select the variants with the smallest content length

<li>Select the first variant of those remaining (this will be either the
first listed in the type-map file, or the first read from the directory)
and go to stage 3.

</ol>

<li>The algorithm has now selected one 'best' variant, so return
  it as the response. The HTTP response header Vary is set to indicate the
  dimensions of negotiation (browsers and caches can use this
  information when caching the resource). End.

<li>To get here means no variant was selected (because non are acceptable
  to the browser). Return a 406 status (meaning "No acceptable representation")
  with a response body consisting of an HTML document listing the
  available variants. Also set the HTTP Vary header to indicate the
  dimensions of variance.

</ol>
<h2><a name="better">Fiddling with Quality Values</a></h2>

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
full or accurate information. Some of the most popular browsers send
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.
<p>

<h3>Media Types and Wildcards</h3>

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:
<pre>
  Accept: image/*, */*
</pre>

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:
<pre>
  Accept: text/html, text/plain, image/gif, image/jpeg, */*
</pre>

The intention of this is to indicate that the explicitly
listed types are preferred, but if a different representation is
available, that is ok too. However under the basic algorithm, as given
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:
<pre>
  Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01
</pre>

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. 
<p>

If the Accept: header contains <i>no</i> 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 <i>not</i> applied, so requests from browsers
which send the correct information to start with work as expected.

<h3>Variants with no Language</h3>

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.<p>

The reason for setting this language quality factor for
variant with no language to a very low value is to allow
for a default variant which can be supplied if none of the
other variants match the browser's language preferences. 

For example, consider the situation with three variants:

<ul>
<li>foo.en.html, language en
<li>foo.fr.html, language en
<li>foo.html, no language
</ul>

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
or foo.fr.html will be returned. If the browser does not list
either en or fr as acceptable, foo.html will be returned instead.

<h2>Note on Caching</h2>

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
subject to content negotiation at the server, this would result in
only the first requested variant being cached, and subsequent cache
hits could return the wrong response. To prevent this, 
Apache normally marks all responses that are returned after content negotiation
as non-cacheable by HTTP/1.0 clients. Apache also supports the HTTP/1.1 
protocol features to allow caching of negotiated responses. <P>

For requests which come from a HTTP/1.0 compliant client (either a
browser or a cache), the directive <tt>CacheNegotiatedDocs</tt> 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
clients.

<!--#include virtual="footer.html" -->
</BODY>
</HTML>

docs/manual/custom-error.html.en

deleted100644 → 0
+0 −153

File deleted.

Preview size limit exceeded, changes collapsed.

Loading