]> granicus.if.org Git - apache/blob - docs/manual/filter.xml
update revision references
[apache] / docs / manual / filter.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="filter.xml.meta">
24
25   <title>Filters</title>
26
27   <summary>
28     <p>This document describes the use of filters in Apache.</p>
29   </summary>
30
31   <section id="intro">
32     <title>Filtering in Apache 2</title>
33     <related>
34       <modulelist>
35         <module>mod_filter</module>
36         <module>mod_deflate</module>
37         <module>mod_ext_filter</module>
38         <module>mod_include</module>
39         <module>mod_charset_lite</module>
40       </modulelist>
41       <directivelist>
42         <directive module="mod_filter">FilterChain</directive>
43         <directive module="mod_filter">FilterDeclare</directive>
44         <directive module="mod_filter">FilterProtocol</directive>
45         <directive module="mod_filter">FilterProvider</directive>
46         <directive module="mod_mime">AddInputFilter</directive>
47         <directive module="mod_mime">AddOutputFilter</directive>
48         <directive module="mod_mime">RemoveInputFilter</directive>
49         <directive module="mod_mime">RemoveOutputFilter</directive>
50         <directive module="mod_ext_filter">ExtFilterDefine</directive>
51         <directive module="mod_ext_filter">ExtFilterOptions</directive>
52         <directive module="core">SetInputFilter</directive>
53         <directive module="core">SetOutputFilter</directive>
54       </directivelist>
55     </related>
56
57 <p>The Filter Chain is available in Apache 2.0 and higher,
58 and enables applications to process incoming and outgoing data
59 in a highly flexible and configurable manner, regardless of
60 where the data comes from.  We can pre-process incoming data,
61 and post-process outgoing data, at will.  This is basically
62 independent of the traditional request processing phases.</p>
63 <p class="figure">
64 <img src="images/filter_arch.png" width="569" height="392" alt=
65 "Filters can be chained, in a Data Axis orthogonal to request processing"
66 />
67 </p>
68 <p>Some examples of filtering in the standard Apache distribution are:</p>
69 <ul>
70 <li><module>mod_include</module>, implements server-side includes.</li>
71 <li><module>mod_ssl</module>, implements SSL encryption (https).</li>
72 <li><module>mod_deflate</module>, implements compression/decompression on the fly.</li>
73 <li><module>mod_charset_lite</module>, transcodes between different character sets.</li>
74 <li><module>mod_ext_filter</module>, runs an external program as a filter.</li>
75 </ul>
76 <p>Apache also uses a number of filters internally to perform
77 functions like chunking and byte-range handling.</p>
78
79 <p>A wider range of applications are implemented by third-party filter
80 modules available from <a
81 href="http://modules.apache.org/">modules.apache.org</a> and
82 elsewhere.  A few of these are:</p>
83
84 <ul>
85 <li>HTML and XML processing and rewriting</li>
86 <li>XSLT transforms and XIncludes</li>
87 <li>XML Namespace support</li>
88 <li>File Upload handling and decoding of HTML Forms</li>
89 <li>Image processing</li>
90 <li>Protection of vulnerable applications such as PHP scripts</li>
91 <li>Text search-and-replace editing</li>
92 </ul>
93 </section>
94
95 <section id="smart">
96 <title>Smart Filtering</title>
97 <p class="figure">
98 <img src="images/mod_filter_new.png" width="423" height="331"
99 alt="Smart filtering applies different filter providers according to the state of request processing"/>
100 </p>
101 <p><module>mod_filter</module>, included in Apache 2.1 and later,
102 enables the filter chain to be configured dynamically at run time.
103 So for example you can set up a proxy to rewrite
104 HTML with an HTML filter and JPEG images with a completely
105 separate filter, despite the proxy having no prior information
106 about what the origin server will send.  This works by using a
107 filter harness, that dispatches to different providers according
108 to the actual contents at runtime.  Any filter may be either
109 inserted directly in the chain and run unconditionally, or
110 used as a provider and inserted dynamically.  For example,</p>
111 <ul>
112 <li>an HTML processing filter will only run if the content is
113 text/html or application/xhtml+xml</li>
114 <li>A compression filter will only run if the input is a
115 compressible type and not already compressed</li>
116 <li>A charset conversion filter will be inserted if a text
117 document is not already in the desired charset</li>
118 </ul>
119 </section>
120
121 <section id="using">
122 <title>Using Filters</title>
123 <p>There are two ways to use filtering: Simple and Dynamic.
124 In general, you should use one or the other; mixing them can
125 have unexpected consequences (although simple Input filtering
126 can be mixed freely with either simple or dynamic Output filtering).</p>
127 <p>The Simple Way is the only way to configure input filters, and is
128 sufficient for output filters where you need a static filter chain.
129 Relevant directives are
130     <directive module="core">SetInputFilter</directive>,
131     <directive module="core">SetOutputFilter</directive>,
132     <directive module="mod_mime">AddInputFilter</directive>,
133     <directive module="mod_mime">AddOutputFilter</directive>,
134     <directive module="mod_mime">RemoveInputFilter</directive>, and
135     <directive module="mod_mime">RemoveOutputFilter</directive>.</p>
136
137 <p>The Dynamic Way enables both static and flexible, dynamic configuration
138 of output filters, as discussed in the <module>mod_filter</module> page.
139 Relevant directives are
140     <directive module="mod_filter">FilterChain</directive>,
141     <directive module="mod_filter">FilterDeclare</directive>, and
142     <directive module="mod_filter">FilterProvider</directive>.</p>
143
144 <p>One further directive <directive
145 module="core">AddOutputFilterByType</directive> is still supported,
146 but may be problematic and is now deprecated.  Use dynamic
147 configuration instead.</p>
148
149   </section>
150 </manualpage>