<p>To activate the example module, include a block similar to
the following in your <code>httpd.conf</code> file:</p>
-<div class="example"><p><code>
- <Location /example-info><br />
- SetHandler example-handler<br />
- </Location>
-</code></p></div>
+<pre class="prettyprint lang-config">
+<Location /example-info>
+ SetHandler example-handler
+</Location>
+</pre>
+
<p>As an alternative, you can put the following into a <a href="core.html#accessfilename"><code>.htaccess</code></a> file
and then request the file "test.example" from that location:</p>
-<div class="example"><p><code>
+<pre class="prettyprint lang-config">
AddHandler example-handler .example
-</code></p></div>
+</pre>
+
<p>After reloading/restarting your server, you should be able
to browse to this location and see the brief display mentioned
<h2><a name="examples" id="examples">Examples</a></h2>
<h3>Generating HTML from some other type of response</h3>
- <div class="example"><p><code>
- # mod_ext_filter directive to define a filter<br />
- # to HTML-ize text/c files using the external<br />
- # program /usr/bin/enscript, with the type of<br />
- # the result set to text/html<br />
- ExtFilterDefine c-to-html mode=output \<br />
- <span class="indent">
- intype=text/c outtype=text/html \<br />
- cmd="/usr/bin/enscript --color -W html -Ec -o - -"<br />
- </span>
- <br />
- <Directory "/export/home/trawick/apacheinst/htdocs/c"><br />
- <span class="indent">
- # core directive to cause the new filter to<br />
- # be run on output<br />
- SetOutputFilter c-to-html<br />
- <br />
- # mod_mime directive to set the type of .c<br />
- # files to text/c<br />
- AddType text/c .c<br />
- <br />
- </span>
- </Directory>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# mod_ext_filter directive to define a filter
+# to HTML-ize text/c files using the external
+# program /usr/bin/enscript, with the type of
+# the result set to text/html
+ExtFilterDefine c-to-html mode=output \
+ intype=text/c outtype=text/html \
+ cmd="/usr/bin/enscript --color -W html -Ec -o - -"
+
+<Directory "/export/home/trawick/apacheinst/htdocs/c">
+ # core directive to cause the new filter to
+ # be run on output
+ SetOutputFilter c-to-html
+
+ # mod_mime directive to set the type of .c
+ # files to text/c
+ AddType text/c .c
+</Directory>
+ </pre>
+
<h3>Implementing a content encoding filter</h3>
Please refer to <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> for a practical
implementation.</p>
- <div class="example"><p><code>
- # mod_ext_filter directive to define the external filter<br />
- ExtFilterDefine gzip mode=output cmd=/bin/gzip<br />
- <br />
- <Location /gzipped><br />
- <span class="indent">
- # core directive to cause the gzip filter to be<br />
- # run on output<br />
- SetOutputFilter gzip<br />
- <br />
- # mod_header directive to add<br />
- # "Content-Encoding: gzip" header field<br />
- Header set Content-Encoding gzip<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# mod_ext_filter directive to define the external filter
+ExtFilterDefine gzip mode=output cmd=/bin/gzip
+
+<Location /gzipped>
+
+ # core directive to cause the gzip filter to be
+ # run on output
+ SetOutputFilter gzip
+
+ # mod_header directive to add
+ # "Content-Encoding: gzip" header field
+ Header set Content-Encoding gzip
+</Location>
+ </pre>
+
<h3>Slowing down the server</h3>
- <div class="example"><p><code>
- # mod_ext_filter directive to define a filter<br />
- # which runs everything through cat; cat doesn't<br />
- # modify anything; it just introduces extra pathlength<br />
- # and consumes more resources<br />
- ExtFilterDefine slowdown mode=output cmd=/bin/cat \<br />
- <span class="indent">
- preservescontentlength<br />
- </span>
- <br />
- <Location /><br />
- <span class="indent">
- # core directive to cause the slowdown filter to<br />
- # be run several times on output<br />
- #<br />
- SetOutputFilter slowdown;slowdown;slowdown<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# mod_ext_filter directive to define a filter
+# which runs everything through cat; cat doesn't
+# modify anything; it just introduces extra pathlength
+# and consumes more resources
+ExtFilterDefine slowdown mode=output cmd=/bin/cat \
+ preservescontentlength
+
+<Location />
+ # core directive to cause the slowdown filter to
+ # be run several times on output
+ #
+ SetOutputFilter slowdown;slowdown;slowdown
+</Location>
+ </pre>
+
<h3>Using sed to replace text in the response</h3>
- <div class="example"><p><code>
- # mod_ext_filter directive to define a filter which<br />
- # replaces text in the response<br />
- #<br />
- ExtFilterDefine fixtext mode=output intype=text/html \<br />
- <span class="indent">
- cmd="/bin/sed s/verdana/arial/g"<br />
- </span>
- <br />
- <Location /><br />
- <span class="indent">
- # core directive to cause the fixtext filter to<br />
- # be run on output<br />
- SetOutputFilter fixtext<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# mod_ext_filter directive to define a filter which
+# replaces text in the response
+#
+ExtFilterDefine fixtext mode=output intype=text/html \
+ cmd="/bin/sed s/verdana/arial/g"
+
+<Location />
+ # core directive to cause the fixtext filter to
+ # be run on output
+ SetOutputFilter fixtext
+</Location>
+ </pre>
+
<h3>Tracing another filter</h3>
- <div class="example"><p><code>
- # Trace the data read and written by mod_deflate<br />
- # for a particular client (IP 192.168.1.31)<br />
- # experiencing compression problems.<br />
- # This filter will trace what goes into mod_deflate.<br />
- ExtFilterDefine tracebefore \<br />
- <span class="indent">
- cmd="/bin/tracefilter.pl /tmp/tracebefore" \<br />
- EnableEnv=trace_this_client<br />
- </span>
- <br />
- # This filter will trace what goes after mod_deflate.<br />
- # Note that without the ftype parameter, the default<br />
- # filter type of AP_FTYPE_RESOURCE would cause the<br />
- # filter to be placed *before* mod_deflate in the filter<br />
- # chain. Giving it a numeric value slightly higher than<br />
- # AP_FTYPE_CONTENT_SET will ensure that it is placed<br />
- # after mod_deflate.<br />
- ExtFilterDefine traceafter \<br />
- <span class="indent">
- cmd="/bin/tracefilter.pl /tmp/traceafter" \<br />
- EnableEnv=trace_this_client ftype=21<br />
- </span>
- <br />
- <Directory /usr/local/docs><br />
- <span class="indent">
- SetEnvIf Remote_Addr 192.168.1.31 trace_this_client<br />
- SetOutputFilter tracebefore;deflate;traceafter<br />
- </span>
- </Directory>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# Trace the data read and written by mod_deflate
+# for a particular client (IP 192.168.1.31)
+# experiencing compression problems.
+# This filter will trace what goes into mod_deflate.
+ExtFilterDefine tracebefore \
+ cmd="/bin/tracefilter.pl /tmp/tracebefore" \
+ EnableEnv=trace_this_client
+
+# This filter will trace what goes after mod_deflate.
+# Note that without the ftype parameter, the default
+# filter type of AP_FTYPE_RESOURCE would cause the
+# filter to be placed *before* mod_deflate in the filter
+# chain. Giving it a numeric value slightly higher than
+# AP_FTYPE_CONTENT_SET will ensure that it is placed
+# after mod_deflate.
+ExtFilterDefine traceafter \
+ cmd="/bin/tracefilter.pl /tmp/traceafter" \
+ EnableEnv=trace_this_client ftype=21
+
+<Directory /usr/local/docs>
+ SetEnvIf Remote_Addr 192.168.1.31 trace_this_client
+ SetOutputFilter tracebefore;deflate;traceafter
+</Directory>
+ </pre>
+
<div class="example"><h3>Here is the filter which traces the data:</h3><p><code>
- #!/usr/local/bin/perl -w<br />
- use strict;<br />
- <br />
- open(SAVE, ">$ARGV[0]")<br />
- <span class="indent">
- or die "can't open $ARGV[0]: $?";<br />
- </span>
- <br />
- while (<STDIN>) {<br />
- <span class="indent">
- print SAVE $_;<br />
- print $_;<br />
- </span>
- }<br />
- <br />
- close(SAVE);
+ <pre class="prettyprint lang-perl">
+#!/usr/local/bin/perl -w
+use strict;
+
+open(SAVE, ">$ARGV[0]")
+ or die "can't open $ARGV[0]: $?";
+
+while (<STDIN>) {
+ print SAVE $_;
+ print $_;
+}
+
+close(SAVE);
+ </pre>
+
</code></p></div>
</div>
filter is removed and the request continues without it.</dd>
</dl>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
ExtFilterOptions LogStderr
- </code></p></div>
+ </pre>
+
<p>Messages written to the filter's standard error will be stored
in the Apache error log.</p>
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
CacheFile /usr/local/apache/htdocs/index.html
+ </pre>
+
</code></p></div>
</div>
<code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
MMapFile /usr/local/apache/htdocs/index.html
+ </pre>
+
</code></p></div>
</div>
<dl>
<dt>Server side Includes (SSI)</dt>
<dd>A simple case of replacing <code class="directive">AddOutputFilterByType</code>
- <div class="example"><p><code>
- FilterDeclare SSI<br />
- FilterProvider SSI INCLUDES "%{CONTENT_TYPE} =~ m|^text/html|"<br />
- FilterChain SSI
- </code></p></div>
+ <pre class="prettyprint lang-config">
+FilterDeclare SSI
+FilterProvider SSI INCLUDES "%{CONTENT_TYPE} =~ m|^text/html|"
+FilterChain SSI
+ </pre>
+
</dd>
<dt>Server side Includes (SSI)</dt>
<dd>The same as the above but dispatching on handler (classic
SSI behaviour; .shtml files get processed).
- <div class="example"><p><code>
- FilterProvider SSI INCLUDES "%{HANDLER} = 'server-parsed'"<br />
- FilterChain SSI
- </code></p></div>
+ <pre class="prettyprint lang-config">
+FilterProvider SSI INCLUDES "%{HANDLER} = 'server-parsed'"
+FilterChain SSI
+ </pre>
+
</dd>
<dt>Emulating mod_gzip with mod_deflate</dt>
<dd>Insert INFLATE filter only if "gzip" is NOT in the
Accept-Encoding header. This filter runs with ftype CONTENT_SET.
- <div class="example"><p><code>
- FilterDeclare gzip CONTENT_SET<br />
- FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip/"<br />
- FilterChain gzip
- </code></p></div>
+ <pre class="prettyprint lang-config">
+FilterDeclare gzip CONTENT_SET
+FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip/"
+FilterChain gzip
+ </pre>
+
</dd>
<dt>Image Downsampling</dt>
<dd>Suppose we want to downsample all web images, and have filters
for GIF, JPEG and PNG.
- <div class="example"><p><code>
- FilterProvider unpack jpeg_unpack "%{CONTENT_TYPE} = 'image/jpeg'"<br />
- FilterProvider unpack gif_unpack "%{CONTENT_TYPE} = 'image/gif'"<br />
- FilterProvider unpack png_unpack "%{CONTENT_TYPE} = 'image/png'"<br />
- <br />
- FilterProvider downsample downsample_filter "%{CONTENT_TYPE} = m|^image/(jpeg|gif|png)|"<br />
- FilterProtocol downsample "change=yes"<br />
- <br />
- FilterProvider repack jpeg_pack "%{CONTENT_TYPE} = 'image/jpeg'"<br />
- FilterProvider repack gif_pack "%{CONTENT_TYPE} = 'image/gif'"<br />
- FilterProvider repack png_pack "%{CONTENT_TYPE} = 'image/png'"<br />
- <Location /image-filter><br />
- <span class="indent">
- FilterChain unpack downsample repack<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+FilterProvider unpack jpeg_unpack "%{CONTENT_TYPE} = 'image/jpeg'"
+FilterProvider unpack gif_unpack "%{CONTENT_TYPE} = 'image/gif'"
+FilterProvider unpack png_unpack "%{CONTENT_TYPE} = 'image/png'"
+
+FilterProvider downsample downsample_filter "%{CONTENT_TYPE} = m|^image/(jpeg|gif|png)|"
+FilterProtocol downsample "change=yes"
+
+FilterProvider repack jpeg_pack "%{CONTENT_TYPE} = 'image/jpeg'"
+FilterProvider repack gif_pack "%{CONTENT_TYPE} = 'image/gif'"
+FilterProvider repack png_pack "%{CONTENT_TYPE} = 'image/png'"
+<Location /image-filter>
+ FilterChain unpack downsample repack
+</Location>
+ </pre>
+
</dd>
</dl>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<code>text/html</code> or <code>text/plain</code> before it is sent
to the client.</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
AddOutputFilterByType DEFLATE text/html text/plain
- </code></p></div>
+ </pre>
+
<p>If you want the content to be processed by more than one filter, their
names have to be separated by semicolons. It's also possible to use one
<code>INCLUDES</code> filter and then by the <code>DEFLATE</code>
filter.</p>
- <div class="example"><p><code>
- <Location /cgi-bin/><br />
- <span class="indent">
- Options Includes<br />
- AddOutputFilterByType INCLUDES;DEFLATE text/html<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+<Location /cgi-bin/>
+ Options Includes
+ AddOutputFilterByType INCLUDES;DEFLATE text/html
+</Location>
+ </pre>
+
<h3>See also</h3>
present.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseConnectionInput connection-input.firehose
+ </pre>
+
</code></p></div>
</div>
keepalive is present.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseConnectionOutput connection-output.firehose
+ </pre>
+
</code></p></div>
</div>
<p>Capture traffic being received by mod_proxy.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseProxyConnectionInput proxy-input.firehose
+ </pre>
+
</code></p></div>
</div>
<p>Capture traffic being sent out by mod_proxy.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseProxyConnectionOutput proxy-output.firehose
+ </pre>
+
</code></p></div>
</div>
will be captured separately, regardless of the presence of keepalive.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseRequestInput request-input.firehose
+ </pre>
+
</code></p></div>
</div>
will be captured separately, regardless of the presence of keepalive.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
FirehoseRequestOutput request-output.firehose
+ </pre>
+
</code></p></div>
</div>
<p>The following directive will activate files ending with
<code>.map</code> as imagemap files:</p>
- <div class="example"><p><code>AddHandler imap-file map</code></p></div>
+ <pre class="prettyprint lang-config">AddHandler imap-file map</pre>
+
<p>Note that the following is still supported:</p>
- <div class="example"><p><code>AddType application/x-httpd-imap map</code></p></div>
+ <pre class="prettyprint lang-config">AddType application/x-httpd-imap map</pre>
+
<p>However, we are trying to phase out "magic MIME types" so we
are deprecating this method.</p>
parse them and assign the resulting document the mime type of
<code>text/html</code>:</p>
- <div class="example"><p><code>
- AddType text/html .shtml<br />
- AddOutputFilter INCLUDES .shtml
- </code></p></div>
+ <pre class="prettyprint lang-config">
+AddType text/html .shtml
+AddOutputFilter INCLUDES .shtml
+ </pre>
+
<p>The following directive must be given for the directories
containing the shtml files (typically in a
<code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> <code>Options</code>
is set):</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
Options +Includes
- </code></p></div>
+ </pre>
+
<p>For backwards compatibility, the <code>server-parsed</code>
<a href="../handler.html">handler</a> also activates the
<p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
looks for to mark the end of an include element.</p>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
SSIEndTag "%>"
- </code></p></div>
+ </pre>
+
<h3>See also</h3>
<p>This directive has the same effect as the <code><!--#config
errmsg=<var>message</var> --></code> element.</p>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
SSIErrorMsg "<!-- Error -->"
- </code></p></div>
+ </pre>
+
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
output of a file each processing different commands (possibly at
different times).</p>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
SSIStartTag "<%"<br />
SSIEndTag "%>"
- </code></p></div>
+ </pre>
+
<p>The example given above, which also specifies a matching
<code class="directive"><a href="#ssiendtag">SSIEndTag</a></code>, will
<p>This directive has the same effect as the <code><!--#config
timefmt=<var>formatstring</var> --></code> element.</p>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
SSITimeFormat "%R, %B %d, %Y"
- </code></p></div>
+ </pre>
+
<p>The above directive would cause times to be displayed in the
format "22:26, June 14, 2002".</p>
<p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
displays when a variable is not set and "echoed".</p>
- <div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
SSIUndefinedEcho "<!-- undef -->"
- </code></p></div>
+ </pre>
+
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<li>
Log message after request to /foo/* is processed:
- <div class="example"><p><code>
- <Location /foo/><br />
- LogMessage "/foo/ has been requested"<br />
- </Location><br />
- </code></p></div>
+ <pre class="prettyprint lang-config">
+<Location /foo/>
+ LogMessage "/foo/ has been requested"
+</Location>
+ </pre>
+
</li>
<li>
Log message if request to /foo/* is processed in a sub-request:
- <div class="example"><p><code>
- <Location /foo/><br />
- LogMessage "subrequest to /foo/" hook=type_checker expr=%{IS_SUBREQ}<br />
- </Location><br />
- </code></p></div>
+ <pre class="prettyprint lang-config">
+<Location /foo/>
+ LogMessage "subrequest to /foo/" hook=type_checker expr=%{IS_SUBREQ}
+</Location>
+ </pre>
+
The default log_transaction hook is not executed for sub-requests,
therefore we have to use a different hook.
<li>
Log message if an IPv6 client causes a request timeout:
- <div class="example"><p><code>
- LogMessage "IPv6 timeout from %{REMOTE_ADDR}"
- "expr=-T %{IPV6} && %{REQUEST_STATUS} = 408"
- </code></p></div>
+ <pre class="prettyprint lang-config">
+ LogMessage "IPv6 timeout from %{REMOTE_ADDR}" "expr=-T %{IPV6} && %{REQUEST_STATUS} = 408"
+ </pre>
+
Note the placing of the double quotes for the <code>expr=</code> argument.
</li>
<li>
Log the value of the "X-Foo" request environment variable in each
stage of the request:
- <div class="example"><p><code>
- <Location /><br />
- LogMessage "%{reqenv:X-Foo}" hook=all<br />
- </Location><br />
- </code></p></div>
+ <pre class="prettyprint lang-config">
+<Location />
+ LogMessage "%{reqenv:X-Foo}" hook=all
+</Location>
+ </pre>
+
Together with microsecond time stamps in the error log,
<code>hook=all</code> also allows to determine the times spent
in the different parts of the request processing.
of using <code>AddHandler cgi-script .cgi</code>, use</p>
<div class="example"><h3>Configure handler based on final extension only</h3><p><code>
- <FilesMatch \.cgi$>
- <span class="indent">
- SetHandler cgi-script
- </span>
- </FilesMatch>
+ <pre class="prettyprint lang-config">
+<FilesMatch \.cgi$>
+ SetHandler cgi-script
+</FilesMatch>
+ </pre>
+
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
resource, in order to tell the client browser about the
encoding method.</p>
- <div class="example"><p><code>Content-encoding: pkzip</code></p></div>
+ <pre class="prettyprint lang-config">Content-encoding: pkzip</pre>
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="charset-lang" id="charset-lang">Character sets and languages</a></h2>
render the information.</p>
<div class="example"><p><code>
- Content-Language: en, fr<br />
- Content-Type: text/plain; charset=ISO-8859-1
+Content-Language: en, fr
+Content-Type: text/plain; charset=ISO-8859-1
</code></p></div>
<p>The language specification is the two-letter abbreviation
<var>extension</var>.</p>
<div class="example"><h3>Example</h3><p><code>
- AddLanguage ja .ja<br />
- AddCharset EUC-JP .euc<br />
- AddCharset ISO-2022-JP .jis<br />
- AddCharset SHIFT_JIS .sjis
+ <pre class="prettyprint lang-config">
+AddLanguage ja .ja
+AddCharset EUC-JP .euc
+AddCharset ISO-2022-JP .jis
+AddCharset SHIFT_JIS .sjis
+ </pre>
+
</code></p></div>
<p>Then the document <code>xxxx.ja.jis</code> will be treated
<var>extension</var>.</p>
<div class="example"><h3>Example</h3><p><code>
- AddEncoding x-gzip .gz<br />
- AddEncoding x-compress .Z
+ <pre class="prettyprint lang-config">
+AddEncoding x-gzip .gz
+AddEncoding x-compress .Z
+ </pre>
+
</code></p></div>
<p>This will cause filenames containing the <code>.gz</code> extension
activate CGI scripts with the file extension <code>.cgi</code>, you
might use:</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
AddHandler cgi-script .cgi
- </code></p></div>
+ </pre>
+
<p>Once that has been put into your httpd.conf file, any file containing
the <code>.cgi</code> extension will be treated as a CGI program.</p>
<var>extension</var>.</p>
<div class="example"><h3>Example</h3><p><code>
- AddEncoding x-compress .Z<br />
- AddLanguage en .en<br />
- AddLanguage fr .fr
+ <pre class="prettyprint lang-config">
+AddEncoding x-compress .Z
+AddLanguage en .en
+AddLanguage fr .fr
+ </pre>
+
</code></p></div>
<p>Then the document <code>xxxx.en.Z</code> will be treated as
extension, the last one encountered is the one that is used.
That is, for the case of:</p>
- <div class="example"><p><code>
- AddLanguage en .en<br />
- AddLanguage en-gb .en<br />
- AddLanguage en-us .en
- </code></p></div>
+ <pre class="prettyprint lang-config">
+AddLanguage en .en
+AddLanguage en-gb .en
+AddLanguage en-us .en
+ </pre>
+
<p>documents with the extension <code>.en</code> would be treated as
being <code>en-us</code>.</p>
<code>.shtml</code> files for server-side includes and will then
compress the output using <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code>.</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
AddOutputFilter INCLUDES;DEFLATE shtml
- </code></p></div>
+ </pre>
+
<p>If more than one filter is specified, they must be separated
by semicolons in the order in which they should process the
the <code class="directive"><a href="#addoutputfilter">AddOutputFilter</a></code>
directive.</p>
- <div class="example"><p><code>
- # Effective filter "DEFLATE"<br />
- AddOutputFilter DEFLATE shtml<br />
- <Location /foo><br />
- <span class="indent">
- # Effective filter "INCLUDES", replacing "DEFLATE"<br />
- AddOutputFilter INCLUDES shtml<br />
- </span>
- </Location><br />
- <Location /bar><br />
- <span class="indent">
- # Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"<br />
- AddOutputFilter INCLUDES;DEFLATE shtml<br />
- </span>
- </Location><br />
- <Location /bar/baz><br />
- <span class="indent">
- # Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"<br />
- AddOutputFilter BUFFER shtml<br />
- </span>
- </Location><br />
- <Location /bar/baz/buz><br />
- <span class="indent">
- # No effective filter, replacing "BUFFER"<br />
- RemoveOutputFilter shtml<br />
- </span>
- </Location>
- </code></p></div>
+ <pre class="prettyprint lang-config">
+# Effective filter "DEFLATE"
+AddOutputFilter DEFLATE shtml
+<Location /foo>
+ # Effective filter "INCLUDES", replacing "DEFLATE"
+ AddOutputFilter INCLUDES shtml
+</Location>
+<Location /bar>
+ # Effective filter "INCLUDES;DEFLATE", replacing "DEFLATE"
+ AddOutputFilter INCLUDES;DEFLATE shtml
+</Location>
+<Location /bar/baz>
+ # Effective filter "BUFFER", replacing "INCLUDES;DEFLATE"
+ AddOutputFilter BUFFER shtml
+</Location>
+<Location /bar/baz/buz>
+ # No effective filter, replacing "BUFFER"
+ RemoveOutputFilter shtml
+</Location>
+ </pre>
+
<h3>See also</h3>
<ul>
</div>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
AddType image/gif .gif
+ </pre>
+
</code></p></div>
<p>Or, to specify multiple file extensions in one directive:</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
AddType image/jpeg jpeg jpg jpe
+ </pre>
+
</code></p></div>
<p>The <var>extension</var> argument is case-insensitive and can
<code>qs</code>:</p>
<div class="example"><h3>Example</h3><p><code>
- Addtype application/rss+xml;qs=0.8 .xml
+ <pre class="prettyprint lang-config">
+ AddType application/rss+xml;qs=0.8 .xml
+ </pre>
+
</code></p></div>
<p>This is useful in situations, <em>e.g.</em> when a client
Content-Language header field will be generated.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
DefaultLanguage en
+ </pre>
+
</code></p></div>
<h3>See also</h3>
<p>This directive is recommended when you have a virtual filesystem.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
ModMimeUsePathInfo On
+ </pre>
+
</code></p></div>
<p>If you have a request for <code>/index.php/foo.shtml</code>
and filters to participate in Multviews, but will exclude unknown
files:</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
MultiviewsMatch Handlers Filters
- </code></p></div>
+ </pre>
+
<p><code class="directive">MultiviewsMatch</code> is not allowed in a
<code class="directive"><a href="../mod/core.html#location"><Location></a></code> or <code class="directive"><a href="../mod/core.html#locationmatch"><LocationMatch></a></code> section.</p>
be specified with or without a leading dot.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
RemoveCharset .html .shtml
+ </pre>
+
</code></p></div>
</div>
server config files. An example of its use might be:</p>
<div class="example"><h3>/foo/.htaccess:</h3><p><code>
- AddEncoding x-gzip .gz<br />
- AddType text/plain .asc<br />
- <Files *.gz.asc><br />
- <span class="indent">
- RemoveEncoding .gz<br />
- </span>
- </Files>
+ <pre class="prettyprint lang-config">
+AddEncoding x-gzip .gz
+AddType text/plain .asc
+<Files *.gz.asc>
+ RemoveEncoding .gz
+</Files>
+ </pre>
+
</code></p></div>
<p>This will cause <code>foo.gz</code> to be marked as being
config files. An example of its use might be:</p>
<div class="example"><h3>/foo/.htaccess:</h3><p><code>
+ <pre class="prettyprint lang-config">
AddHandler server-parsed .html
+ </pre>
+
</code></p></div>
<div class="example"><h3>/foo/bar/.htaccess:</h3><p><code>
+ <pre class="prettyprint lang-config">
RemoveHandler .html
+ </pre>
+
</code></p></div>
<p>This has the effect of returning <code>.html</code> files in
be specified with or without a leading dot.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
RemoveOutputFilter shtml
+ </pre>
+
</code></p></div>
<h3>See also</h3>
might be:</p>
<div class="example"><h3>/foo/.htaccess:</h3><p><code>
+ <pre class="prettyprint lang-config">
RemoveType .cgi
+ </pre>
+
</code></p></div>
<p>This will remove any special handling of <code>.cgi</code>
an HTTP reverse proxy, but uses the <code>ajp://</code> prefix:</p>
<div class="example"><h3>Simple Reverse Proxy</h3><p><code>
+ <pre class="prettyprint lang-config">
ProxyPass /app ajp://backend.example.com:8009/app
+ </pre>
+
</code></p></div>
<p>Balancers may also be used:</p>
<div class="example"><h3>Balancer Reverse Proxy</h3><p><code>
- <Proxy balancer://cluster><br />
- <span class="indent">
- BalancerMember ajp://app1.example.com:8009 loadfactor=1<br />
- BalancerMember ajp://app2.example.com:8009 loadfactor=2<br />
- ProxySet lbmethod=bytraffic<br />
- </span>
- </Proxy><br />
- ProxyPass /app balancer://cluster/app
+ <pre class="prettyprint lang-config">
+<Proxy balancer://cluster>
+ BalancerMember ajp://app1.example.com:8009 loadfactor=1
+ BalancerMember ajp://app2.example.com:8009 loadfactor=2
+ ProxySet lbmethod=bytraffic
+</Proxy>
+ProxyPass /app balancer://cluster/app
+ </pre>
+
</code></p></div>
<p>Note that usually no
original host URL (not the backend <code>ajp://</code> URL), for
example:</p>
<div class="example"><h3>Rewriting Proxied Path</h3><p><code>
- ProxyPass /apps/foo ajp://backend.example.com:8009/foo<br />
- ProxyPassReverse /apps/foo http://www.example.com/foo
+ <pre class="prettyprint lang-config">
+ProxyPass /apps/foo ajp://backend.example.com:8009/foo
+ProxyPassReverse /apps/foo http://www.example.com/foo
+ </pre>
+
</code></p></div>
<p>However, it is usually better to deploy the application on the backend
server at the same path as the proxy rather than to take this approach.
load balancing between two back-end servers:
</p>
- <div class="example"><p><code>
- <Proxy balancer://mycluster><br />
- BalancerMember http://192.168.1.50:80<br />
- BalancerMember http://192.168.1.51:80<br />
- </Proxy><br />
- ProxyPass /test balancer://mycluster<br />
- ProxyPassReverse /test balancer://mycluster
- </code></p></div>
+ <pre class="prettyprint lang-config">
+<Proxy balancer://mycluster>
+ BalancerMember http://192.168.1.50:80
+ BalancerMember http://192.168.1.51:80
+</Proxy>
+ProxyPass /test balancer://mycluster
+ProxyPassReverse /test balancer://mycluster
+ </pre>
+
<p>Another example of how to provide load balancing with stickyness
using <code class="module"><a href="../mod/mod_headers.html">mod_headers</a></code>, even if the back-end server does
not set a suitable session cookie:
</p>
- <div class="example"><p><code>
- Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/"
- env=BALANCER_ROUTE_CHANGED<br />
- <Proxy balancer://mycluster><br />
- BalancerMember http://192.168.1.50:80 route=1<br />
- BalancerMember http://192.168.1.51:80 route=2<br />
- ProxySet stickysession=ROUTEID<br />
- </Proxy><br />
- ProxyPass /test balancer://mycluster<br />
- ProxyPassReverse /test balancer://mycluster
- </code></p></div>
+ <pre class="prettyprint lang-config">
+Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
+<Proxy balancer://mycluster>
+ BalancerMember http://192.168.1.50:80 route=1
+ BalancerMember http://192.168.1.51:80 route=2
+ ProxySet stickysession=ROUTEID
+</Proxy>
+ProxyPass /test balancer://mycluster
+ProxyPassReverse /test balancer://mycluster
+ </pre>
+
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="environment" id="environment">Exported Environment Variables</a></h2>
<p>To enable load balancer management for browsers from the example.com
domain add this code to your <code>httpd.conf</code>
configuration file</p>
-<div class="example"><p><code>
- <Location /balancer-manager><br />
- SetHandler balancer-manager<br />
-<br />
- Require host example.com<br />
- </Location>
-</code></p></div>
+<pre class="prettyprint lang-config">
+<Location /balancer-manager>
+ SetHandler balancer-manager
+ Require host example.com
+</Location>
+</pre>
+
<p>You can now access load balancer manager by using a Web browser
to access the page
<div class="example"><pre>application/octet-stream bin dms lha lzh exe class tgz taz</pre></div>
<p>Alternatively you may prefer to default everything to binary:</p>
- <div class="example"><pre>ForceType application/octet-stream</pre></div>
+ <div class="example"><p><code>
+ <pre class="prettyprint lang-config">ForceType application/octet-stream</pre>
+
+ </code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="type" id="type">How can I force an FTP ASCII download of
<var>session</var>, configure the session as follows:</p>
<div class="example"><h3>Browser based session</h3><p><code>
- Session On<br />
- SessionCookieName session path=/<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionCookieName session path=/
+ </pre>
+
</code></p></div>
<p>For more examples on how the session can be configured to be read
</p>
<div class="example"><h3>Cookie with attributes</h3><p><code>
- Session On<br />
- SessionCookieName session path=/private;domain=example.com;httponly;secure;version=1;<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionCookieName session path=/private;domain=example.com;httponly;secure;version=1;
+ </pre>
+
</code></p></div>
</p>
<div class="example"><h3>Cookie2 with attributes</h3><p><code>
- Session On<br />
- SessionCookieName2 session path=/private;domain=example.com;httponly;secure;version=1;<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionCookieName2 session path=/private;domain=example.com;httponly;secure;version=1;
+ </pre>
+
</code></p></div>
<var>session</var>, configure the session as follows:</p>
<div class="example"><h3>Browser based encrypted session</h3><p><code>
- Session On<br />
- SessionCookieName session path=/<br />
- SessionCryptoPassphrase secret
+ <pre class="prettyprint lang-config">
+Session On
+SessionCookieName session path=/
+SessionCryptoPassphrase secret
+ </pre>
+
</code></p></div>
<p>The session will be encrypted with the given key. Different servers can
which are specified as parameters with optional values after the driver name.</p>
<div class="example"><h3>NSS without a certificate database</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver nss
+ </pre>
+
</code></p></div>
<div class="example"><h3>NSS with certificate database</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver nss dir=certs
+ </pre>
+
</code></p></div>
<div class="example"><h3>NSS with certificate database and parameters</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver nss dir=certs key3=key3.db cert7=cert7.db secmod=secmod
+ </pre>
+
</code></p></div>
<div class="example"><h3>NSS with paths containing spaces</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver nss "dir=My Certs" key3=key3.db cert7=cert7.db secmod=secmod
+ </pre>
+
</code></p></div>
<p>The <var>NSS</var> crypto driver might have already been configured by another
To avoid this warning, use the noinit parameter as follows.</p>
<div class="example"><h3>NSS with certificate database</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver nss noinit
+ </pre>
+
</code></p></div>
<p>To prevent confusion, ensure that all modules requiring NSS are configured with
the engine to be used for encryption.</p>
<div class="example"><h3>OpenSSL with engine support</h3><p><code>
+ <pre class="prettyprint lang-config">
SessionCryptoDriver openssl engine=name
+ </pre>
+
</code></p></div>
session. These queries are configured as per the example below.</p>
<div class="example"><h3>Sample DBD configuration</h3><p><code>
- DBDriver pgsql<br />
- DBDParams "dbname=apachesession user=apache password=xxxxx host=localhost"<br />
- DBDPrepareSQL "delete from session where key = %s" deletesession<br />
- DBDPrepareSQL "update session set value = %s, expiry = %lld where key = %s" updatesession<br />
- DBDPrepareSQL "insert into session (value, expiry, key) values (%s, %lld, %s)" insertsession<br />
- DBDPrepareSQL "select value from session where key = %s and (expiry = 0 or expiry > %lld)" selectsession<br />
- DBDPrepareSQL "delete from session where expiry != 0 and expiry < %lld" cleansession<br />
+ <pre class="prettyprint lang-config">
+DBDriver pgsql
+DBDParams "dbname=apachesession user=apache password=xxxxx host=localhost"
+DBDPrepareSQL "delete from session where key = %s" deletesession
+DBDPrepareSQL "update session set value = %s, expiry = %lld where key = %s" updatesession
+DBDPrepareSQL "insert into session (value, expiry, key) values (%s, %lld, %s)" insertsession
+DBDPrepareSQL "select value from session where key = %s and (expiry = 0 or expiry > %lld)" selectsession
+DBDPrepareSQL "delete from session where expiry != 0 and expiry < %lld" cleansession
+ </pre>
+
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
called <var>session</var>, configure the session as follows:</p>
<div class="example"><h3>SQL based anonymous session</h3><p><code>
- Session On<br />
- SessionDBDCookieName session path=/<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionDBDCookieName session path=/
+ </pre>
+
</code></p></div>
<p>For more examples on how the session can be configured to be read
userid, configure the session as follows:</p>
<div class="example"><h3>SQL based per user session</h3><p><code>
- Session On<br />
- SessionDBDPerUser On<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionDBDPerUser On
+ </pre>
+
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
</p>
<div class="example"><h3>Cookie with attributes</h3><p><code>
- Session On<br />
- SessionDBDCookieName session path=/private;domain=example.com;httponly;secure;version=1;<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionDBDCookieName session path=/private;domain=example.com;httponly;secure;version=1;
+ </pre>
+
</code></p></div>
</p>
<div class="example"><h3>Cookie2 with attributes</h3><p><code>
- Session On<br />
- SessionDBDCookieName2 session path=/private;domain=example.com;httponly;secure;version=1;<br />
+ <pre class="prettyprint lang-config">
+Session On
+SessionDBDCookieName2 session path=/private;domain=example.com;httponly;secure;version=1;
+ </pre>
+
</code></p></div>
<p>For example, to make the server accept connections on both
port 80 and port 8000, use:</p>
- <div class="example"><p><code>
- Listen 80<br />
- Listen 8000
- </code></p></div>
+ <pre class="prettyprint lang-config">
+Listen 80
+Listen 8000
+ </pre>
+
<p>To make the server accept connections on two specified
interfaces and port numbers, use </p>
- <div class="example"><p><code>
- Listen 192.170.2.1:80<br />
- Listen 192.170.2.5:8000
- </code></p></div>
+ <pre class="prettyprint lang-config">
+Listen 192.170.2.1:80
+Listen 192.170.2.5:8000
+ </pre>
+
<p>IPv6 addresses must be surrounded in square brackets, as in the
following example:</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
Listen [2001:db8::a00:20ff:fea7:ccea]:80
- </code></p></div>
+ </pre>
+
<p>The optional <var>protocol</var> argument is not required for most
configurations. If not specified, <code>https</code> is the default for
<p>You only need to set the protocol if you are running on non-standard
ports. For example, running an <code>https</code> site on port 8443:</p>
- <div class="example"><p><code>
+ <pre class="prettyprint lang-config">
Listen 192.170.2.1:8443 https
- </code></p></div>
+ </pre>
+
<div class="note"><h3>Error condition</h3>
Multiple <code class="directive">Listen</code> directives for the same ip
<code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
PidFile /var/run/apache.pid
+ </pre>
+
</code></p></div>
<p>It is often useful to be able to send the server a signal,
Apache httpd to always create the file on the disk.</p>
<div class="example"><h3>Example</h3><p><code>
+ <pre class="prettyprint lang-config">
ScoreBoardFile /var/run/apache_status
+ </pre>
+
</code></p></div>
<p>File-based shared memory is useful for third-party applications