filter.xml revision 663cbde3169bcfadb51937e7c3af75307c5af91c
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version="1.0" encoding="UTF-8" ?>
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive<!-- $LastChangedRevision$ -->
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive<!--
b686b6a420bde7f78c416b90be11db94cb789979nd Licensed to the Apache Software Foundation (ASF) under one or more
b686b6a420bde7f78c416b90be11db94cb789979nd contributor license agreements. See the NOTICE file distributed with
b686b6a420bde7f78c416b90be11db94cb789979nd this work for additional information regarding copyright ownership.
b686b6a420bde7f78c416b90be11db94cb789979nd The ASF licenses this file to You under the Apache License, Version 2.0
b686b6a420bde7f78c416b90be11db94cb789979nd (the "License"); you may not use this file except in compliance with
b686b6a420bde7f78c416b90be11db94cb789979nd the License. You may obtain a copy of the License at
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd http://www.apache.org/licenses/LICENSE-2.0
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd Unless required by applicable law or agreed to in writing, software
b686b6a420bde7f78c416b90be11db94cb789979nd distributed under the License is distributed on an "AS IS" BASIS,
b686b6a420bde7f78c416b90be11db94cb789979nd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd See the License for the specific language governing permissions and
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd limitations under the License.
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd-->
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd<manualpage metafile="filter.xml.meta">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <title>Filters</title>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
b686b6a420bde7f78c416b90be11db94cb789979nd <summary>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <p>This document describes the use of filters in Apache.</p>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </summary>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <section id="intro">
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <title>Filtering in Apache 2</title>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <related>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <modulelist>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <module>mod_filter</module>
5b10fd3977e6dfff19afe770e612e276962f7950nd <module>mod_deflate</module>
5b10fd3977e6dfff19afe770e612e276962f7950nd <module>mod_ext_filter</module>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <module>mod_include</module>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <module>mod_charset_lite</module>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <module>mod_reflector</module>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd </modulelist>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <directivelist>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <directive module="mod_filter">FilterChain</directive>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <directive module="mod_filter">FilterDeclare</directive>
5b10fd3977e6dfff19afe770e612e276962f7950nd <directive module="mod_filter">FilterProtocol</directive>
5b10fd3977e6dfff19afe770e612e276962f7950nd <directive module="mod_filter">FilterProvider</directive>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <directive module="mod_mime">AddInputFilter</directive>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <directive module="mod_mime">AddOutputFilter</directive>
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mod_mime">RemoveInputFilter</directive>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <directive module="mod_mime">RemoveOutputFilter</directive>
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mod_reflector">ReflectorHeader</directive>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <directive module="mod_ext_filter">ExtFilterDefine</directive>
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna <directive module="mod_ext_filter">ExtFilterOptions</directive>
7fa75a06a4fee19e995c069ee00310455d1452e1pquerna <directive module="core">SetInputFilter</directive>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd <directive module="core">SetOutputFilter</directive>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd </directivelist>
2aff288113d772cedca6add888eb643afffe9fb1nd </related>
2aff288113d772cedca6add888eb643afffe9fb1nd
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<p>The Filter Chain is available in Apache 2.0 and higher,
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndand enables applications to process incoming and outgoing data
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndin a highly flexible and configurable manner, regardless of
2aff288113d772cedca6add888eb643afffe9fb1ndwhere the data comes from. We can pre-process incoming data,
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndand post-process outgoing data, at will. This is basically
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2ndindependent of the traditional request processing phases.</p>
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<p class="figure">
a63f0ab647ad2ab72efc9bea7a66e24e9ebc5cc2nd<img src="images/filter_arch.png" width="569" height="392" alt=
2aff288113d772cedca6add888eb643afffe9fb1nd"Filters can be chained, in a Data Axis orthogonal to request processing"
2aff288113d772cedca6add888eb643afffe9fb1nd/>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<p>Some examples of filtering in the standard Apache distribution are:</p>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<ul>
db99fa79ac42b9cc42b63386eb289aecb0f3cb9cnd<li><module>mod_include</module>, implements server-side includes.</li>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<li><module>mod_ssl</module>, implements SSL encryption (https).</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li><module>mod_deflate</module>, implements compression/decompression on the fly.</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li><module>mod_charset_lite</module>, transcodes between different character sets.</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li><module>mod_ext_filter</module>, runs an external program as a filter.</li>
2aff288113d772cedca6add888eb643afffe9fb1nd</ul>
2aff288113d772cedca6add888eb643afffe9fb1nd<p>Apache also uses a number of filters internally to perform
2aff288113d772cedca6add888eb643afffe9fb1ndfunctions like chunking and byte-range handling.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<p>A wider range of applications are implemented by third-party filter
2aff288113d772cedca6add888eb643afffe9fb1ndmodules available from <a
2aff288113d772cedca6add888eb643afffe9fb1ndhref="http://modules.apache.org/">modules.apache.org</a> and
2aff288113d772cedca6add888eb643afffe9fb1ndelsewhere. A few of these are:</p>
aa0b2780958e9b1467c9d0153a05738e399811a5nd
2aff288113d772cedca6add888eb643afffe9fb1nd<ul>
42af92a661a06b3cebc88d585aad75064a309d51nd<li>HTML and XML processing and rewriting</li>
42af92a661a06b3cebc88d585aad75064a309d51nd<li>XSLT transforms and XIncludes</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li>XML Namespace support</li>
aa0b2780958e9b1467c9d0153a05738e399811a5nd<li>File Upload handling and decoding of HTML Forms</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li>Image processing</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li>Protection of vulnerable applications such as PHP scripts</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li>Text search-and-replace editing</li>
64c02f1310b7747423957823ee09fb3608430f89nd</ul>
aa0b2780958e9b1467c9d0153a05738e399811a5nd</section>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<section id="smart">
2aff288113d772cedca6add888eb643afffe9fb1nd<title>Smart Filtering</title>
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<p class="figure">
2aff288113d772cedca6add888eb643afffe9fb1nd<img src="images/mod_filter_new.png" width="423" height="331"
2aff288113d772cedca6add888eb643afffe9fb1ndalt="Smart filtering applies different filter providers according to the state of request processing"/>
2aff288113d772cedca6add888eb643afffe9fb1nd</p>
2aff288113d772cedca6add888eb643afffe9fb1nd<p><module>mod_filter</module>, included in Apache 2.1 and later,
2aff288113d772cedca6add888eb643afffe9fb1ndenables the filter chain to be configured dynamically at run time.
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndSo for example you can set up a proxy to rewrite
2aff288113d772cedca6add888eb643afffe9fb1ndHTML with an HTML filter and JPEG images with a completely
e67fa8d3f161e595dd448fc24a591ee17ae59131ndseparate filter, despite the proxy having no prior information
05ede5110427cb9dc071cc671d5aaba5d3b88c79ndabout what the origin server will send. This works by using a
bf94bedcb62d7f0b926f4286069def5ee6b07b60ndfilter harness, that dispatches to different providers according
bf94bedcb62d7f0b926f4286069def5ee6b07b60ndto the actual contents at runtime. Any filter may be either
2aff288113d772cedca6add888eb643afffe9fb1ndinserted directly in the chain and run unconditionally, or
2aff288113d772cedca6add888eb643afffe9fb1ndused as a provider and inserted dynamically. For example,</p>
bbcbf978a3074512c627c797fedcb30eeab7b39dslive<ul>
ee5db395bc3723609919edfa96af387eea37c491jim<li>an HTML processing filter will only run if the content is
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndtext/html or application/xhtml+xml</li>
2aff288113d772cedca6add888eb643afffe9fb1nd<li>A compression filter will only run if the input is a
e55e60efce8a3e2139132c1d6ad9f6f0d2976614ndcompressible type and not already compressed</li>
e55e60efce8a3e2139132c1d6ad9f6f0d2976614nd<li>A charset conversion filter will be inserted if a text
2aff288113d772cedca6add888eb643afffe9fb1nddocument is not already in the desired charset</li>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive</ul>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive</section>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd<section id="service">
75585bd48fe0f30483dba4762e61edf39ea3e0f6nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd<title>Exposing Filters as an HTTP Service</title>
03a4ff9ac4c9b8009249010e7c53bb86ff05915and<p>Filters can be used to process content originating from the client in
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndaddition to processing content originating on the server using the
3b58542e01ec69422f3086db5825a12fc77b726end<module>mod_reflector</module> module.</p>
a0d937b340692a3578f1d2f2535890c520c4bf0cnd
a0d937b340692a3578f1d2f2535890c520c4bf0cnd<p><module>mod_reflector</module> accepts POST requests from clients, and reflects
2aff288113d772cedca6add888eb643afffe9fb1ndthe content request body received within the POST request back in the response,
2aff288113d772cedca6add888eb643afffe9fb1ndpassing through the output filter stack on the way back to the client.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<p>This technique can be used as an alternative to a web service running within
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndan application server stack, where an output filter provides the transformation
08842292d2f1550b40ae73e0dafc7641c5955c82ndrequired on the request body. For example, the <module>mod_deflate</module>
2aff288113d772cedca6add888eb643afffe9fb1ndmodule might be used to provide a general compression service, or an image
d2b809e5d72658bff23819d8b77f20e4939af541ndtransformation filter might be turned into an image transformation service.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd</section>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<section id="using">
2aff288113d772cedca6add888eb643afffe9fb1nd<title>Using Filters</title>
2aff288113d772cedca6add888eb643afffe9fb1nd<p>There are two ways to use filtering: Simple and Dynamic.
2aff288113d772cedca6add888eb643afffe9fb1ndIn general, you should use one or the other; mixing them can
2aff288113d772cedca6add888eb643afffe9fb1ndhave unexpected consequences (although simple Input filtering
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndcan be mixed freely with either simple or dynamic Output filtering).</p>
c023f60e35022146373e40249f0c8c8d623b6fcfnd<p>The Simple Way is the only way to configure input filters, and is
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndsufficient for output filters where you need a static filter chain.
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977ndRelevant directives are
a43bfa789f4e52dde53ae8e53fa0427b5c1cf977nd <directive module="core">SetInputFilter</directive>,
101bf3584c853027d9e51df6edfff5ff70c80238jim <directive module="core">SetOutputFilter</directive>,
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd <directive module="mod_mime">AddInputFilter</directive>,
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd <directive module="mod_mime">AddOutputFilter</directive>,
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd <directive module="mod_mime">RemoveInputFilter</directive>, and
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd <directive module="mod_mime">RemoveOutputFilter</directive>.</p>
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd
73ba54c33b4fcad0e13005e10ea8648c9fe4265bnd<p>The Dynamic Way enables both static and flexible, dynamic configuration
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42ndof output filters, as discussed in the <module>mod_filter</module> page.
2aff288113d772cedca6add888eb643afffe9fb1ndRelevant directives are
80d3dc69b0e6ad772135f6a78af3d16bd6cccc42nd <directive module="mod_filter">FilterChain</directive>,
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mod_filter">FilterDeclare</directive>, and
2aff288113d772cedca6add888eb643afffe9fb1nd <directive module="mod_filter">FilterProvider</directive>.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd<p>One further directive <directive
2aff288113d772cedca6add888eb643afffe9fb1ndmodule="mod_filter">AddOutputFilterByType</directive> is still supported,
2aff288113d772cedca6add888eb643afffe9fb1ndbut deprecated. Use dynamic configuration instead.</p>
2aff288113d772cedca6add888eb643afffe9fb1nd
2aff288113d772cedca6add888eb643afffe9fb1nd </section>
2aff288113d772cedca6add888eb643afffe9fb1nd</manualpage>
2aff288113d772cedca6add888eb643afffe9fb1nd