Cross Reference: /httpd/docs/manual/filter.xml
filter.xml revision bf899a0078232507bf2e3bfcd6eb56c48c609a2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
4655N/A<?xml version="1.0" encoding="UTF-8" ?>
6323N/A<!DOCTYPE manualpage SYSTEM "/style/manualpage.dtd">
4655N/A<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
4655N/A<!-- $LastChangedRevision$ -->
4655N/A
4655N/A<!--
4655N/A Copyright 2002-2005 The Apache Software Foundation or its licensors, as
4655N/A applicable.
4655N/A
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
4655N/A http://www.apache.org/licenses/LICENSE-2.0
4655N/A
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-->
4655N/A
4655N/A<manualpage metafile="filter.xml.meta">
4655N/A
4655N/A <title>Filters</title>
4655N/A
4655N/A <summary>
4655N/A <p>This document describes the use of filters in Apache.</p>
4655N/A </summary>
4655N/A
4655N/A <section id="intro">
4655N/A <title>Filtering in Apache 2</title>
4655N/A <related>
4655N/A <modulelist>
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>
4655N/A </modulelist>
4858N/A <directivelist>
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 </directivelist>
4655N/A </related>
4655N/A
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<p class="figure">
4655N/A<img src="images/filter_arch.png" width="569" height="392" alt=
4655N/A"Filters can be chained, in a Data Axis orthogonal to request processing"
4655N/A/>
4655N/A</p>
4655N/A<p>Some examples of filtering in the standard Apache distribution are:</p>
4655N/A<ul>
4655N/A<li>mod_includes, implements server-side includes.</li>
4655N/A<li>mod_ssl, implements SSL encryption (https).</li>
4655N/A<li>mod_deflate, implements compression/decompression on the fly.</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</ul>
4655N/A<p>Apache also uses a number of filters internally, to perform
4655N/Afunctions like chunking and byte-range handling.</p>
4655N/A
4655N/A<p>A wider range of applications are implemented by third-party
4655N/Afilter modules. A few of these are:</p>
4655N/A<ul>
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>Image processing</li>
4655N/A<li>Protection of vulnerable applications such as PHP scripts</li>
4655N/A<li>Text search-and-replace editing</li>
5041N/A</ul>
4655N/A</section>
5041N/A<section id="smart">
5041N/A<title>Smart Filtering</title>
4655N/A<p class="figure">
4655N/A<img src="images/mod_filter_new.png" width="423" height="331"
4655N/Aalt="Smart filtering applies different filter providers according to the state of request processing"/>
4655N/A</p>
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<ul>
4655N/A<li>an HTML processing filter will only run if the content is
4655N/Atext/html or application/xhtml+xml</li>
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</ul>
4655N/A</section>
4655N/A
4655N/A<section id="using">
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/ARelevant directives are
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
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/ARelevant directives are
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
4655N/Ainstead.</p>
4655N/A </section>
4655N/A</manualpage>
4655N/A