Cleanup html docs using dpatch
[manu/mod-proxy-html.git] / config.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html lang="en"><head>
4 <title>mod_proxy_html</title>
5 <style type="text/css">
6 @import url(/index.css) ;
7 </style>
8 </head><body>
9 <div id="apache">
10 <h1>mod_proxy_html: Configuration</h1>
11 <p><a href="./">mod_proxy_html</a> Version 3.1 (April 2009).</p>
12 <h2>Configuration Directives</h2>
13 <p>The following can be used anywhere in an <strong>httpd.conf</strong>
14 or included configuration file.</p>
15 <dl>
16 <dt>ProxyHTMLEnable</dt>
17 <dd>
18 <p>Syntax: <code>ProxyHTMLEnable On|Off</code></p>
19 <p>Enables mod_proxy_html filtering in a scope (<code>&lt;Location&gt;</code>
20 or top level/virtualhost).  This also configures <a href="../mod_xml2enc/"
21 >mod_xml2enc</a> if present, and <strong>replaces</strong> use of
22 any generic filter configuration (e.g. <code>SetOutputFilter</code>
23 or <code>FilterProvider</code>) to configure both these modules.</p></dd>
24 <dt>ProxyHTMLURLMap</dt>
25 <dd>
26 <p>Syntax:
27 <code>ProxyHTMLURLMap   from-pattern    to-pattern [flags] [cond]</code></p>
28 <p>This is the key directive for rewriting HTML links.  When parsing a document,
29 whenever a link target matches <samp>from-pattern</samp>, the matching
30 portion will be rewritten to <samp>to-pattern</samp>.</p>
31 <p>Starting at version 2.0, this supports a wider range of pattern-matching
32 and substitutions, including regular expression search and replace,
33 controlled by the optional third <code>flags</code> argument.
34 </p>
35 <p">Starting at version 3.0, this also supports environment variable
36 interpolation using the V and v flags, and rules may apply conditionally
37 based on an environment variable.  Note that interpolation takes place
38 before the parse starts, so variables set during the parse (e.g.
39 using SSI directives) will not apply.  This flexible configuration
40 is enabled by the <code>ProxyHTMLInterp</code> directive, or can
41 be disabled for speed.</p>
42 <h3>Flags for ProxyHTMLURLMap</h3>
43 <p>Flags are case-sensitive.</p>
44 <dl class="table">
45 <dt>h</dt>
46 <dd><p>Ignore HTML links (pass through unchanged)</p></dd>
47 <dt>e</dt>
48 <dd><p>Ignore scripting events (pass through unchanged)</p></dd>
49 <dt>c</dt>
50 <dd><p>Pass embedded script and style sections through untouched.</p></dd>
51 <dt>L</dt>
52 <dd><p>Last-match.  If this rule matches, no more rules are applied
53 (note that this happens automatically for HTML links).</p></dd>
54 <dt>l</dt>
55 <dd><p>Opposite to L.  Overrides the one-change-only default
56 behaviour with HTML links.</p></dd>
57 <dt>R</dt>
58 <dd><p>Use Regular Expression matching-and-replace.  <code>from-pattern</code>
59 is a regexp, and <code>to-pattern</code> a replacement string that may be
60 based on the regexp.  Regexp memory is supported: you can use brackets ()
61 in the <code>from-pattern</code> and retrieve the matches with $1 to $9
62 in the <code>to-pattern</code>.</p>
63 <p>If R is not set, it will use string-literal search-and-replace, as in
64 versions 1.x.  Logic is <em>starts-with</em> in HTML links, but
65 <em>contains</em> in scripting events and embedded script and style sections.
66 </p>
67 </dd>
68 <dt>x</dt>
69 <dd><p>Use POSIX extended Regular Expressions.  Only applicable with R.</p></dd>
70 <dt>i</dt>
71 <dd><p>Case-insensitive matching.  Only applicable with R.</p></dd>
72 <dt>n</dt>
73 <dd><p>Disable regexp memory (for speed).  Only applicable with R.</p></dd>
74 <dt>s</dt>
75 <dd><p>Line-based regexp matching.  Only applicable with R.</p></dd>
76 <dt>^</dt>
77 <dd><p>Match at start only.  This applies only to string matching
78 (not regexps) and is irrelevant to HTML links.</p></dd>
79 <dt>$</dt>
80 <dd><p>Match at end only.  This applies only to string matching
81 (not regexps) and is irrelevant to HTML links.</p></dd>
82 <dt>V</dt>
83 <dd><p>Interpolate environment variables in <code>to-pattern</code>.
84 A string of the form <code>${varname|default}</code> will be replaced by the
85 value of environment variable <code>varname</code>.  If that is unset, it
86 is replaced by <code>default</code>.  The <code>|default</code> is optional.</p>
87 <p>NOTE: interpolation will only be enabled if ProxyHTMLInterp is On.</p>
88 </dd>
89 <dt>v</dt>
90 <dd><p>Interpolate environment variables in <code>from-pattern</code>.
91 Patterns supported are as above.</p>
92 <p>NOTE: interpolation will only be enabled if ProxyHTMLInterp is On.</p>
93 </dd>
94 </dl>
95 <h3>Conditions for ProxyHTMLURLMap</h3>
96 <p>The optional <code>cond</code> argument specifies a condition to
97 test before the parse.  If a condition is unsatisfied, the URLMap
98 will be ignored in this parse.</p>
99 <p>The condition takes the form <code>[!]var[=val]</code>, and is
100 satisfied if the value of environment variable <code>var</code>
101 is <code>val</code>.  If the optional <code>=val</code> is omitted,
102 then any value of <code>var</code> satisfies the condition, provided
103 only it is set to something.  If the first character is <code>!</code>,
104 the condition is reversed.</p>
105 <p>NOTE: conditions will only be applied if ProxyHTMLInterp is On.</p>
106 </dd>
107 <dt>ProxyHTMLInterp</dt>
108 <dd>
109 <p>Syntax: <code>ProxyHTMLInterp On|Off</code></p>
110 <p>Enables new (per-request) features of ProxyHTMLURLMap.</p>
111 </dd>
112 <dt>ProxyHTMLDoctype</dt>
113 <dd>
114 <p>Syntax: <code>ProxyHTMLDoctype HTML|XHTML [Legacy]</code></p>
115 <p>Alternative Syntax: <code>ProxyHTMLDocType fpi [SGML|XML]</code></p>
116 <p>In the first form, documents will be declared as HTML 4.01 or XHTML 1.0
117 according to the option selected.  This option also determines whether
118 HTML or XHTML syntax is used for output.   Note that the format of the
119 documents coming from the backend server is immaterial: the parser will
120 deal with it automatically.  If the optional second argument is set to
121 "Legacy", documents will be declared "Transitional", an option that may
122 be necessary if you are proxying pre-1998 content or working with defective
123 authoring/publishing tools.</p>
124 <p>In the second form, it will insert your own <abbr
125 title="Formal Public Identifier">FPI</abbr>.  The optional second
126 argument determines whether SGML/HTML or XML/XHTML syntax will be used.</p>
127 <p>Starting at version 2.0, the default is changed to omitting any FPI,
128 on the grounds that no FPI is better than a bogus one.  If your backend
129 generates decent HTML or XHTML, set it accordingly.</p>
130 <p>From version 3, if the first form is used, mod_proxy_html
131 will also clean up the HTML to the specified standard.  It cannot
132 fix every error, but it will strip out bogus elements and attributes.
133 It will also optionally log other errors at <tt>LogLevel Debug</tt>.</p>
134 </dd>
135 <dt>ProxyHTMLFixups</dt>
136 <dd>
137 <p>Syntax: <code>ProxyHTMLFixups [lowercase] [dospath] [reset]</code></p>
138 <p>This directive takes one to three arguments as follows:</p>
139 <ul>
140 <li><code>lowercase</code> Urls are rewritten to lowercase</li>
141 <li><code>dospath</code> Backslashes in URLs are rewritten to forward slashes.</li>
142 <li><code>reset</code> Unset any options set at a higher level in the configuration.</li>
143 </ul>
144 <p>Take care when using these.  The fixes will correct certain authoring
145 mistakes, but risk also erroneously fixing links that were correct to start with.
146 Only use them if you know you have a broken backend server.</p> 
147 </dd>
148 <dt>ProxyHTMLMeta</dt>
149 <dd><p>Syntax <code>ProxyHTMLMeta [On|Off]</code></p>
150 <p>Parses <code>&lt;meta http-equiv ...&gt;</code> elements to real HTTP
151 headers.</p>
152 <p>In version 3, this is also tied in with the improved
153 <a href="guide.html#charset">internationalisation support</a>, and is
154 required to support some character encodings.</p>
155 </dd>
156 <dt>ProxyHTMLExtended</dt>
157 <dd><p>Syntax <code>ProxyHTMLExtended [On|Off]</code></p>
158 <p>Set to <code>Off</code>, this gives the same behaviour as 1.x versions
159 of mod_proxy_html.  HTML links are rewritten according the ProxyHTMLURLMap
160 directives, but links appearing in Javascript and CSS are ignored.</p>
161 <p>Set to <code>On</code>, all scripting events and embedded scripts or
162 stylesheets are also processed by the ProxyHTMLURLMap rules, according to
163 the flags set for each rule.  Since this requires more parsing, performance
164 will be best if you only enable it when strictly necessary.</p>
165 </dd>
166 <dt>ProxyHTMLStripComments</dt>
167 <dd><p>Syntax <code>ProxyHTMLStripComments [On|Off]</code></p>
168 <p>This directive will cause mod_proxy_html to strip HTML comments.
169 Note that this will also kill off any scripts or styles embedded in
170 comments (a bogosity introduced in 1995/6 with Netscape 2 for the
171 benefit of then-older browsers, but still in use today).
172 It may also interfere with comment-based processors such as SSI or ESI:
173 be sure to run any of those <em>before</em> mod_proxy_html in the
174 filter chain if stripping comments!</p>
175 </dd>
176 <dt>ProxyHTMLLogVerbose</dt>
177 <dd><p>Syntax <code>ProxyHTMLLogVerbose [On|Off]</code></p>
178 <p>Turns on verbose logging.  This causes mod_proxy_html to make
179 error log entries (at <code>LogLevel Info</code>) about charset
180 detection and about all meta substitutions and rewrites made.
181 When Off, only errors and warnings (if any) are logged.</p>
182 </dd>
183 <dt>ProxyHTMLBufSize</dt>
184 <dd><p>Syntax <code>ProxyHTMLBufSize nnnn</code></p>
185 <p>Set the buffer size increment for buffering inline stylesheets and scripts.</p>
186 <p>In order to parse non-HTML content (stylesheets and scripts), mod_proxy_html
187 has to read the entire script or stylesheet into a buffer.  This buffer will
188 be expanded as necessary to hold the largest script or stylesheet in a page,
189 in increments of [nnnn] as set by this directive.</p>
190 <p>The default is 8192, and will work well for almost all pages.  However,
191 if you know you're proxying a lot of pages containing stylesheets and/or
192 scripts bigger than 8K (that is, for a single script or stylesheet,
193 NOT in total), it will be more efficient to set a larger buffer
194 size and avoid the need to resize the buffer dynamically during a request.
195 </p>
196 </dd>
197 <dt>ProxyHTMLEvents</dt>
198 <dd>
199 <p>Syntax <code>ProxyHTMLEvents attr [attr ...]</code></p>
200 <p>Specifies one or more attributes to treat as scripting events and
201 apply URLMaps to where appropriate.  You can specify any number of
202 attributes in one or more <code>ProxyHTMLEvents</code> directives.
203 The <a href="/svn/apache/filters/proxy_html/">sample configuration</a>
204 defines the events in standard HTML 4 and XHTML 1.</p>
205 </dd>
206 <dt>ProxyHTMLLinks</dt>
207 <dd>
208 <p>Syntax <code>ProxyHTMLLinks elt attr [attr ...]</code></p>
209 <p>Specifies elements that have URL attributes that should be rewritten
210 using standard URLMaps as in versions 1 and 2 of mod_proxy_html.
211 You will need one <code>ProxyHTMLLinks</code> directive per element,
212 but it can have any number of attributes.  The <a
213 href="/svn/apache/filters/proxy_html/">sample configuration</a>
214 defines the HTML links for standard HTML 4 and XHTML 1.</p>
215 </dd>
216 <dt>ProxyHTMLCharsetOut</dt>
217 <dd>
218 <p>Syntax <code>ProxyHTMLCharsetOut name</code></p>
219 <p>This selects an encoding for mod_proxy_html output.  It should not
220 normally be used, as any change from the default <code>UTF-8</code>
221 (Unicode - as used internally by libxml2) will impose an additional
222 processing overhead.  The special token <code>ProxyHTMLCharsetOut *</code>
223 will generate output using the same encoding as the input.</p>
224 </dd>
225 <dt>ProxyHTMLCharsetAlias</dt>
226 <dt>ProxyHTMLCharsetDefault</dt>
227 <dt>ProxyHTMLStartParse</dt>
228 <dd><p>These directives from Version 3.0 are replaced by
229 <a href="../mod_xml2enc/">mod_xml2enc</a>.</p></dd>
230 </dl>
231 <h3>Other Configuration</h3>
232 <p>Normally, mod_proxy_html will refuse to run when not
233 in a proxy or when the contents are not HTML.  This can be overridden
234 (at your own risk) by setting the environment variable
235 <tt>PROXY_HTML_FORCE</tt> (e.g. with the <tt>SetEnv</tt> directive).</p>
236 </div>
237 <div id="navbar"><a class="internal" href="./" title="Up">Up</a>
238 *
239 <a class="internal" href="/" title="WebThing Apache Centre">Home</a>
240 *
241 <a class="internal" href="/contact.html" title="Contact WebThing">Contact</a>
242 *
243 <a class="external" href="http://www.webthing.com/" title="WebThing Ltd">Web&#222;ing</a>
244 *
245 <a class="external" href="http://www.apache.org/" title="Apache Software Foundation">Apache</a></div></body></html>