]> granicus.if.org Git - apache/blob - docs/manual/filter.html.en
Patch from info@mathijs.info to use 2.4 authz syntax.
[apache] / docs / manual / filter.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>Filters - Apache HTTP Server Version 2.5</title>
11 <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" />
14 <script src="./style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="./images/favicon.ico" rel="shortcut icon" /></head>
18 <body id="manual-page"><div id="page-header">
19 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
20 <p class="apache">Apache HTTP Server Version 2.5</p>
21 <img alt="" src="./images/feather.gif" /></div>
22 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
23 <div id="path">
24 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="./">Version 2.5</a></div><div id="page-content"><div id="preamble"><h1>Filters</h1>
25 <div class="toplang">
26 <p><span>Available Languages: </span><a href="./en/filter.html" title="English">&nbsp;en&nbsp;</a> |
27 <a href="./es/filter.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
28 <a href="./fr/filter.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
29 <a href="./ja/filter.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
30 <a href="./ko/filter.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
31 <a href="./tr/filter.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
32 </div>
33
34     <p>This document describes the use of filters in Apache.</p>
35   </div>
36 <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#intro">Filtering in Apache 2</a></li>
37 <li><img alt="" src="./images/down.gif" /> <a href="#smart">Smart Filtering</a></li>
38 <li><img alt="" src="./images/down.gif" /> <a href="#service">Exposing Filters as an HTTP Service</a></li>
39 <li><img alt="" src="./images/down.gif" /> <a href="#using">Using Filters</a></li>
40 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
41 <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
42 <div class="section">
43 <h2><a name="intro" id="intro">Filtering in Apache 2</a></h2>
44     
45     <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="./mod/mod_filter.html">mod_filter</a></code></li><li><code class="module"><a href="./mod/mod_deflate.html">mod_deflate</a></code></li><li><code class="module"><a href="./mod/mod_ext_filter.html">mod_ext_filter</a></code></li><li><code class="module"><a href="./mod/mod_include.html">mod_include</a></code></li><li><code class="module"><a href="./mod/mod_charset_lite.html">mod_charset_lite</a></code></li><li><code class="module"><a href="./mod/mod_reflector.html">mod_reflector</a></code></li><li><code class="module"><a href="./mod/mod_buffer.html">mod_buffer</a></code></li><li><code class="module"><a href="./mod/mod_data.html">mod_data</a></code></li><li><code class="module"><a href="./mod/mod_ratelimit.html">mod_ratelimit</a></code></li><li><code class="module"><a href="./mod/mod_reqtimeout.html">mod_reqtimeout</a></code></li><li><code class="module"><a href="./mod/mod_request.html">mod_request</a></code></li><li><code class="module"><a href="./mod/mod_sed.html">mod_sed</a></code></li><li><code class="module"><a href="./mod/mod_substitute.html">mod_substitute</a></code></li><li><code class="module"><a href="./mod/mod_xml2enc.html">mod_xml2enc</a></code></li><li><code class="module"><a href="./mod/mod_proxy_html.html">mod_proxy_html</a></code></li><li><code class="module"><a href="./mod/mod_policy.html">mod_policy</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/mod_filter.html#filterchain">FilterChain</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterdeclare">FilterDeclare</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterprotocol">FilterProtocol</a></code></li><li><code class="directive"><a href="./mod/mod_filter.html#filterprovider">FilterProvider</a></code></li><li><code class="directive"><a href="./mod/mod_mime.html#addinputfilter">AddInputFilter</a></code></li><li><code class="directive"><a href="./mod/mod_mime.html#addoutputfilter">AddOutputFilter</a></code></li><li><code class="directive"><a href="./mod/mod_mime.html#removeinputfilter">RemoveInputFilter</a></code></li><li><code class="directive"><a href="./mod/mod_mime.html#removeoutputfilter">RemoveOutputFilter</a></code></li><li><code class="directive"><a href="./mod/mod_reflector.html#reflectorheader">ReflectorHeader</a></code></li><li><code class="directive"><a href="./mod/mod_ext_filter.html#extfilterdefine">ExtFilterDefine</a></code></li><li><code class="directive"><a href="./mod/mod_ext_filter.html#extfilteroptions">ExtFilterOptions</a></code></li><li><code class="directive"><a href="./mod/core.html#setinputfilter">SetInputFilter</a></code></li><li><code class="directive"><a href="./mod/core.html#setoutputfilter">SetOutputFilter</a></code></li></ul></td></tr></table>
46
47 <p>The Filter Chain is available in Apache 2.0 and higher,
48 and enables applications to process incoming and outgoing data
49 in a highly flexible and configurable manner, regardless of
50 where the data comes from.  We can pre-process incoming data,
51 and post-process outgoing data, at will.  This is basically
52 independent of the traditional request processing phases.</p>
53 <p class="figure">
54 <img src="images/filter_arch.png" width="569" height="392" alt="Filters can be chained, in a Data Axis orthogonal to request processing" />
55 </p>
56 <p>Some examples of filtering in the standard Apache distribution are:</p>
57 <ul>
58 <li><code class="module"><a href="./mod/mod_include.html">mod_include</a></code>, implements server-side includes.</li>
59 <li><code class="module"><a href="./mod/mod_ssl.html">mod_ssl</a></code>, implements SSL encryption (https).</li>
60 <li><code class="module"><a href="./mod/mod_deflate.html">mod_deflate</a></code>, implements compression/decompression on the fly.</li>
61 <li><code class="module"><a href="./mod/mod_charset_lite.html">mod_charset_lite</a></code>, transcodes between different character sets.</li>
62 <li><code class="module"><a href="./mod/mod_ext_filter.html">mod_ext_filter</a></code>, runs an external program as a filter.</li>
63 </ul>
64 <p>Apache also uses a number of filters internally to perform
65 functions like chunking and byte-range handling.</p>
66
67 <p>A wider range of applications are implemented by third-party filter
68 modules available from <a href="http://modules.apache.org/">modules.apache.org</a> and
69 elsewhere.  A few of these are:</p>
70
71 <ul>
72 <li>HTML and XML processing and rewriting</li>
73 <li>XSLT transforms and XIncludes</li>
74 <li>XML Namespace support</li>
75 <li>File Upload handling and decoding of HTML Forms</li>
76 <li>Image processing</li>
77 <li>Protection of vulnerable applications such as PHP scripts</li>
78 <li>Text search-and-replace editing</li>
79 </ul>
80 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
81 <div class="section">
82 <h2><a name="smart" id="smart">Smart Filtering</a></h2>
83
84 <p class="figure">
85 <img src="images/mod_filter_new.png" width="423" height="331" alt="Smart filtering applies different filter providers according to the state of request processing" />
86 </p>
87 <p><code class="module"><a href="./mod/mod_filter.html">mod_filter</a></code>, included in Apache 2.1 and later,
88 enables the filter chain to be configured dynamically at run time.
89 So for example you can set up a proxy to rewrite
90 HTML with an HTML filter and JPEG images with a completely
91 separate filter, despite the proxy having no prior information
92 about what the origin server will send.  This works by using a
93 filter harness, that dispatches to different providers according
94 to the actual contents at runtime.  Any filter may be either
95 inserted directly in the chain and run unconditionally, or
96 used as a provider and inserted dynamically.  For example,</p>
97 <ul>
98 <li>an HTML processing filter will only run if the content is
99 text/html or application/xhtml+xml</li>
100 <li>A compression filter will only run if the input is a
101 compressible type and not already compressed</li>
102 <li>A charset conversion filter will be inserted if a text
103 document is not already in the desired charset</li>
104 </ul>
105 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
106 <div class="section">
107 <h2><a name="service" id="service">Exposing Filters as an HTTP Service</a></h2>
108
109
110 <p>Filters can be used to process content originating from the client in
111 addition to processing content originating on the server using the
112 <code class="module"><a href="./mod/mod_reflector.html">mod_reflector</a></code> module.</p>
113
114 <p><code class="module"><a href="./mod/mod_reflector.html">mod_reflector</a></code> accepts POST requests from clients, and reflects
115 the content request body received within the POST request back in the response,
116 passing through the output filter stack on the way back to the client.</p>
117
118 <p>This technique can be used as an alternative to a web service running within
119 an application server stack, where an output filter provides the transformation
120 required on the request body. For example, the <code class="module"><a href="./mod/mod_deflate.html">mod_deflate</a></code>
121 module might be used to provide a general compression service, or an image
122 transformation filter might be turned into an image transformation service.</p>
123
124 </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
125 <div class="section">
126 <h2><a name="using" id="using">Using Filters</a></h2>
127
128 <p>There are two ways to use filtering: Simple and Dynamic.
129 In general, you should use one or the other; mixing them can
130 have unexpected consequences (although simple Input filtering
131 can be mixed freely with either simple or dynamic Output filtering).</p>
132 <p>The Simple Way is the only way to configure input filters, and is
133 sufficient for output filters where you need a static filter chain.
134 Relevant directives are
135     <code class="directive"><a href="./mod/core.html#setinputfilter">SetInputFilter</a></code>,
136     <code class="directive"><a href="./mod/core.html#setoutputfilter">SetOutputFilter</a></code>,
137     <code class="directive"><a href="./mod/mod_mime.html#addinputfilter">AddInputFilter</a></code>,
138     <code class="directive"><a href="./mod/mod_mime.html#addoutputfilter">AddOutputFilter</a></code>,
139     <code class="directive"><a href="./mod/mod_mime.html#removeinputfilter">RemoveInputFilter</a></code>, and
140     <code class="directive"><a href="./mod/mod_mime.html#removeoutputfilter">RemoveOutputFilter</a></code>.</p>
141
142 <p>The Dynamic Way enables both static and flexible, dynamic configuration
143 of output filters, as discussed in the <code class="module"><a href="./mod/mod_filter.html">mod_filter</a></code> page.
144 Relevant directives are
145     <code class="directive"><a href="./mod/mod_filter.html#filterchain">FilterChain</a></code>,
146     <code class="directive"><a href="./mod/mod_filter.html#filterdeclare">FilterDeclare</a></code>, and
147     <code class="directive"><a href="./mod/mod_filter.html#filterprovider">FilterProvider</a></code>.</p>
148
149 <p>One further directive <code class="directive"><a href="./mod/mod_filter.html#addoutputfilterbytype">AddOutputFilterByType</a></code> is still supported,
150 but deprecated.  Use dynamic configuration instead.</p>
151
152   </div></div>
153 <div class="bottomlang">
154 <p><span>Available Languages: </span><a href="./en/filter.html" title="English">&nbsp;en&nbsp;</a> |
155 <a href="./es/filter.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
156 <a href="./fr/filter.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
157 <a href="./ja/filter.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
158 <a href="./ko/filter.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
159 <a href="./tr/filter.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
160 </div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
161 <script type="text/javascript"><!--//--><![CDATA[//><!--
162 var comments_shortname = 'httpd';
163 var comments_identifier = 'http://httpd.apache.org/docs/trunk/filter.html';
164 (function(w, d) {
165     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
166         d.write('<div id="comments_thread"><\/div>');
167         var s = d.createElement('script');
168         s.type = 'text/javascript';
169         s.async = true;
170         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
171         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
172     }
173     else {
174         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
175     }
176 })(window, document);
177 //--><!]]></script></div><div id="footer">
178 <p class="apache">Copyright 2015 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
179 <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
180 if (typeof(prettyPrint) !== 'undefined') {
181     prettyPrint();
182 }
183 //--><!]]></script>
184 </body></html>