4655N/A<?
xml version="1.0" encoding="UTF-8" ?>
4655N/A<!-- $LastChangedRevision$ --> 4655N/A Copyright 2002-2005 The Apache Software Foundation or its licensors, as 4655N/A Licensed under the Apache License, Version 2.0 (the "License"); 4655N/A you may not use this file except in compliance with the License. 4655N/A You may obtain a copy of the License at 4655N/A Unless required by applicable law or agreed to in writing, software 4655N/A distributed under the License is distributed on an "AS IS" BASIS, 4655N/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4655N/A See the License for the specific language governing permissions and 4655N/A limitations under the License. 4655N/A <
p>This document describes the use of filters in Apache.</
p>
4655N/A <
title>Filtering in Apache 2</
title>
4655N/A <
module>mod_filter</
module>
4858N/A <
module>mod_deflate</
module>
4655N/A <
module>mod_ext_filter</
module>
4655N/A <
module>mod_include</
module>
4655N/A <
module>mod_charset_lite</
module>
4858N/A <
directive module="mod_filter">FilterChain</
directive>
4655N/A <
directive module="mod_filter">FilterDeclare</
directive>
4655N/A <
directive module="mod_filter">FilterProtocol</
directive>
4655N/A <
directive module="mod_filter">FilterProvider</
directive>
4655N/A <
directive module="mod_mime">AddInputFilter</
directive>
4655N/A <
directive module="mod_mime">AddOutputFilter</
directive>
4858N/A <
directive module="mod_mime">RemoveInputFilter</
directive>
4858N/A <
directive module="mod_mime">RemoveOutputFilter</
directive>
4655N/A <
directive module="mod_ext_filter">ExtFilterDefine</
directive>
4655N/A <
directive module="mod_ext_filter">ExtFilterOptions</
directive>
4858N/A <
directive module="core">SetInputFilter</
directive>
4655N/A <
directive module="core">SetOutputFilter</
directive>
4655N/A<
p>The Filter Chain is available in Apache 2.0 and higher,
4655N/Aand enables applications to process incoming and outgoing data
4655N/Ain a highly flexible and configurable manner, regardless of
4655N/Awhere the data comes from. We can pre-process incoming data,
4858N/Aand post-process outgoing data, at will. This is basically
4655N/Aindependent of the traditional request processing phases.</
p>
4655N/A"Filters can be chained, in a Data Axis orthogonal to request processing" 4655N/A<
p>Some examples of filtering in the standard Apache distribution are:</
p>
4655N/A<
li>mod_includes, implements server-side includes.</
li>
4655N/A<
li>mod_ssl, implements SSL encryption (https).</
li>
4655N/A<
li>mod_charset_lite, transcodes between different character sets.</
li>
4655N/A<
li>mod_ext_filter, runs an external program as a filter.</
li>
4655N/A<
p>Apache also uses a number of filters internally, to perform
4655N/Afunctions like chunking and byte-range handling.</
p>
4655N/A<
p>A wider range of applications are implemented by third-party
4655N/Afilter modules. A few of these are:</
p>
4655N/A<
li>HTML and XML processing and rewriting</
li>
4655N/A<
li>XSLT transforms and XIncludes</
li>
4655N/A<
li>XML Namespace support</
li>
4655N/A<
li>File Upload handling and decoding of HTML Forms</
li>
4655N/A<
li>Protection of vulnerable applications such as PHP scripts</
li>
4655N/A<
li>Text search-and-replace editing</
li>
5041N/A<
title>Smart Filtering</
title>
4655N/Aalt="Smart filtering applies different filter providers according to the state of request processing"/>
4655N/A<
p><
module>mod_filter</
module>, included in Apache 2.1 and up,
4655N/Aenables the filter chain to be configured dynamically at run time.
4655N/ASo for example you can set up a proxy to rewrite
4655N/AHTML with an HTML filter and JPEG images with a completely
4655N/Aseparate filter, despite the proxy having no prior information
4655N/Aabout what the origin server will send. This works by using a
4655N/Afilter harness, that dispatches to different providers according
4655N/Ato the actual contents at runtime. Any filter may be either
4655N/Ainserted directly in the chain and run unconditionally, or
4655N/Aused as a provider and inserted dynamically. For example,</
p>
4655N/A<
li>an HTML processing filter will only run if the content is
4655N/A<
li>A compression filter will only run if the input is a
4655N/Acompressable type and not already compressed</
li>
4655N/A<
li>A charset conversion filter will be inserted if a text
4655N/Adocument is not already in the desired charset</
li>
4655N/A<
title>Using Filters</
title>
4655N/A<
p>There are two ways to use filtering: Simple and Dynamic.
5232N/AIn general, you should use one or the other: mixing them can
4655N/Ahave unexpected consequences (although simple Input filtering
4655N/Acan be mixed freely with either simple or dynamic Output filtering!</
p>
4655N/A<
p>The Simple Way is the only way to configure input filters, and is
4655N/Asuficient for output filters where you need a static filter chain.
4655N/A <
directive module="core">SetInputFilter</
directive>,
4655N/A <
directive module="core">SetOutputFilter</
directive>,
4655N/A <
directive module="mod_mime">AddInputFilter</
directive>,
4655N/A <
directive module="mod_mime">AddOutputFilter</
directive>,
4655N/A <
directive module="mod_mime">RemoveInputFilter</
directive>, and
4655N/A <
directive module="mod_mime">RemoveOutputFilter</
directive>.</
p>
4655N/A<
p>The Dynamic Way enables both static and flexible, dynamic configuration
4655N/Aof output filters, as discussed in the <
module>mod_filter</
module> page.
4655N/A <
directive module="mod_filter">FilterChain</
directive>,
4655N/A <
directive module="mod_filter">FilterDeclare</
directive>,
4655N/A <
directive module="mod_filter">FilterProvider</
directive>.</
p>
4655N/A<
p>One further directive AddOutputFilterByType is still supported,
4655N/Abut may be problematic and is now deprecated. Use dynamic configuration