]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_proxy_html.xml
xforms
[apache] / docs / manual / mod / mod_proxy_html.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.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 <modulesynopsis metafile="mod_proxy_html.xml.meta">
24
25 <name>mod_proxy_html</name>
26 <description>Rewrite HTML links in to ensure they are addressable
27 from Clients' networks in a proxy context.</description>
28 <status>Base</status>
29 <sourcefile>mod_proxy_html.c</sourcefile>
30 <identifier>proxy_html_module</identifier>
31 <compatibility>Version 2.4 and later.  Available as a third-party module
32 for earlier 2.x versions</compatibility>
33
34 <summary>
35     <p>This module provides an output filter to rewrite HTML links in a proxy situation, to ensure that links work for users outside the proxy. It serves the same purpose as Apache's ProxyPassReverse directive does for HTTP headers, and is an essential component of a reverse proxy.</p>
36
37 <p>For example, if a company has an application server at appserver.example.com that is only visible from within the company's internal network, and a public webserver <code>www.example.com</code>, they may wish to provide a gateway to the application server at <code>http://www.example.com/appserver/</code>. When the application server links to itself, those links need to be rewritten to work through the gateway. mod_proxy_html serves to rewrite <code>&lt;a href="http://appserver.example.com/foo/bar.html"&gt;foobar&lt;/a&gt;</code> to <code>&lt;a href="http://www.example.com/appserver/foo/bar.html"&gt;foobar&lt;/a&gt;</code> making it accessible from outside.</p>
38
39 <p>mod_proxy_html was originally developed at Web&#222;ing, whose
40 extensive <a href="http://apache.webthing.com/mod_proxy_html/"
41 >documentation</a> may be useful to users.</p>
42 </summary>
43
44 <directivesynopsis>
45 <name>ProxyHTMLMeta</name>
46 <description>Turns on or off extra pre-parsing of metadata in HTML
47 <code>&lt;head&gt;</code> sections.</description>
48 <syntax>ProxyHTMLMeta <var>On|Off</var></syntax>
49 <contextlist><context>server config</context>
50 <context>virtual host</context><context>directory</context>
51 </contextlist>
52 <compatibility>Version 2.4 and later; available as a third-party
53 module for earlier 2.x versions.</compatibility>
54
55 <usage>
56     <p>This turns on or off pre-parsing of metadata in HTML
57     <code>&lt;head&gt;</code> sections.</p>
58     <p>If not required, turning ProxyHTMLMeta Off will give a small
59     performance boost by skipping this parse step.  However, it
60     is sometimes necessary for internationalisation to work correctly.</p>
61     <p>ProxyHTMLMeta has two effects.  Firstly and most importantly
62     it enables detection of character encodings declared in the form</p>
63     <pre>&lt;meta http-equiv="Content-Type" content="text/html;charset=<var>foo</var>"&gt;</pre>
64     <p>or, in the case of an XHTML document, an XML declaration.
65     It is NOT required if the charset is declared in a real HTTP header
66     (which is always preferable) from the backend server, nor if the
67     document is <var>utf-8</var> (unicode) or a subset such as ASCII.
68     You may also be able to dispense with it where documents use a
69     default declared using <directive module="mod_xml2enc"
70     >xml2EncDefault</directive>, but that risks propagating an
71     incorrect declaration.  A <directive>ProxyHTMLCharsetOut</directive>
72     can remove that risk, but is likely to be a bigger processing
73     overhead than enabling ProxyHTMLMeta.</p>
74     <p>The other effect of enabling ProxyHTMLMeta is to parse all
75     <code>&lt;meta http-equiv=...&gt;</code> declarations and convert
76     them to real HTTP headers, in keeping with the original purpose
77     of this form of the HTML &lt;meta&gt; element.</p>
78 </usage>
79 </directivesynopsis>
80
81 <directivesynopsis>
82 <name>ProxyHTMLEnable</name>
83 <description>Turns the proxy_html filter on or off.</description>
84 <syntax>ProxyHTMLEnable <var>On|Off</var></syntax>
85 <contextlist><context>server config</context>
86 <context>virtual host</context><context>directory</context>
87 </contextlist>
88 <compatibility>Version 2.4 and later; available as a third-party
89 module for earlier 2.x versions.</compatibility>
90
91 <usage>
92     <p>A simple switch to enable or disable the proxy_html filter.
93     If <module>mod_xml2enc</module> is loaded it will also automatically
94     set up internationalisation support.</p>
95     <p>Note that the proxy_html filter will only act on HTML data
96     (Content-Type text/html or application/xhtml+xml) and when the
97     data are proxied.  You can override this (at your own risk) by
98     setting the <var>PROXY_HTML_FORCE</var> environment variable.</p>
99 </usage>
100 </directivesynopsis>
101
102 <directivesynopsis>
103 <name>ProxyHTMLURLMap</name>
104 <description>Defines a rule to rewrite HTML links</description>
105 <syntax>ProxyHTMLURLMap <var>from-pattern to-pattern [flags] [cond]</var></syntax>
106 <contextlist><context>server config</context>
107 <context>virtual host</context><context>directory</context>
108 </contextlist>
109 <compatibility>Version 2.4 and later; available as a third-party
110 module for earlier 2.x versions.</compatibility>
111
112 <usage>
113 <p>This is the key directive for rewriting HTML links.  When parsing a document,
114 whenever a link target matches <var>from-pattern</var>, the matching
115 portion will be rewritten to <var>to-pattern</var>, as modified by any
116 flags supplied.</p>
117
118 <p>The optional third argument may define any of the following
119 <strong>Flags</strong>.  Flags are case-sensitive.</p>
120 <dl>
121 <dt>h</dt>
122 <dd><p>Ignore HTML links (pass through unchanged)</p></dd>
123 <dt>e</dt>
124 <dd><p>Ignore scripting events (pass through unchanged)</p></dd>
125 <dt>c</dt>
126 <dd><p>Pass embedded script and style sections through untouched.</p></dd>
127
128 <dt>L</dt>
129 <dd><p>Last-match.  If this rule matches, no more rules are applied
130 (note that this happens automatically for HTML links).</p></dd>
131 <dt>l</dt>
132 <dd><p>Opposite to L.  Overrides the one-change-only default
133 behaviour with HTML links.</p></dd>
134 <dt>R</dt>
135 <dd><p>Use Regular Expression matching-and-replace.  <code>from-pattern</code>
136 is a regexp, and <code>to-pattern</code> a replacement string that may be
137 based on the regexp.  Regexp memory is supported: you can use brackets ()
138 in the <code>from-pattern</code> and retrieve the matches with $1 to $9
139 in the <code>to-pattern</code>.</p>
140
141 <p>If R is not set, it will use string-literal search-and-replace.
142 The logic is <em>starts-with</em> in HTML links, but
143 <em>contains</em> in scripting events and embedded script and style sections.
144 </p>
145 </dd>
146 <dt>x</dt>
147 <dd><p>Use POSIX extended Regular Expressions.  Only applicable with R.</p></dd>
148 <dt>i</dt>
149 <dd><p>Case-insensitive matching.  Only applicable with R.</p></dd>
150
151 <dt>n</dt>
152 <dd><p>Disable regexp memory (for speed).  Only applicable with R.</p></dd>
153 <dt>s</dt>
154 <dd><p>Line-based regexp matching.  Only applicable with R.</p></dd>
155 <dt>^</dt>
156 <dd><p>Match at start only.  This applies only to string matching
157 (not regexps) and is irrelevant to HTML links.</p></dd>
158 <dt>$</dt>
159 <dd><p>Match at end only.  This applies only to string matching
160 (not regexps) and is irrelevant to HTML links.</p></dd>
161 <dt>V</dt>
162 <dd><p>Interpolate environment variables in <code>to-pattern</code>.
163 A string of the form <code>${varname|default}</code> will be replaced by the
164 value of environment variable <code>varname</code>.  If that is unset, it
165 is replaced by <code>default</code>.  The <code>|default</code> is optional.</p>
166 <p>NOTE: interpolation will only be enabled if
167 <directive>ProxyHTMLInterp</directive> is <var>On</var>.</p>
168 </dd>
169
170 <dt>v</dt>
171 <dd><p>Interpolate environment variables in <code>from-pattern</code>.
172 Patterns supported are as above.</p>
173 <p>NOTE: interpolation will only be enabled if
174 <directive>ProxyHTMLInterp</directive> is <var>On</var>.</p>
175 </dd>
176 </dl>
177
178 <p>The optional fourth <strong>cond</strong> argument defines a condition
179 that will be evaluated per Request, provided
180 <directive>ProxyHTMLInterp</directive> is <var>On</var>.
181 If the condition evaluates FALSE the map will not be applied in this request.
182 If TRUE, or if no condition is defined, the map is applied.</p>
183 <p>A <strong>cond</strong> is evaluated by the <a href="../expr.html"
184 >Expression Parser</a>.  In addition, the simpler syntax of conditions
185 in mod_proxy_html 3.x for HTTPD 2.0 and 2.2 is also supported.</p>
186 </usage>
187 </directivesynopsis>
188
189 <directivesynopsis>
190 <name>ProxyHTMLInterp</name>
191 <description>Enables per-request interpolation of
192 <directive>ProxyHTMLURLMap</directive> rules.</description>
193 <syntax>ProxyHTMLInterp <var>On|Off</var></syntax>
194 <contextlist><context>server config</context>
195 <context>virtual host</context><context>directory</context>
196 </contextlist>
197 <compatibility>Version 2.4 and later; available as a third-party
198 for earlier 2.x versions</compatibility>
199
200 <usage>
201     <p>This enables per-request interpolation in
202     <directive>ProxyHTMLURLMap</directive> to- and from- patterns.</p>
203     <p>If interpolation is not enabled, all rules are pre-compiled at startup.
204     With interpolation, they must be re-compiled for every request, which
205     implies an extra processing overhead.  It should therefore be
206     enabled only when necessary.</p>
207 </usage>
208 </directivesynopsis>
209
210 <directivesynopsis>
211 <name>ProxyHTMLDocType</name>
212 <description>Sets an HTML or XHTML document type declaration.</description>
213 <syntax>ProxyHTMLDocType <var>HTML|XHTML [Legacy]</var><br/><strong>OR</strong>
214 <br/>ProxyHTMLDocType <var>fpi [SGML|XML]</var></syntax>
215 <contextlist><context>server config</context>
216 <context>virtual host</context><context>directory</context>
217 </contextlist>
218 <compatibility>Version 2.4 and later; available as a third-party
219 for earlier 2.x versions</compatibility>
220
221 <usage>
222 <p>In the first form, documents will be declared as HTML 4.01 or XHTML 1.0
223 according to the option selected.  This option also determines whether
224 HTML or XHTML syntax is used for output.   Note that the format of the
225 documents coming from the backend server is immaterial: the parser will
226 deal with it automatically.  If the optional second argument is set to
227 "Legacy", documents will be declared "Transitional", an option that may
228 be necessary if you are proxying pre-1998 content or working with defective
229 authoring/publishing tools.</p>
230 <p>In the second form, it will insert your own FPI.  The optional second
231 argument determines whether SGML/HTML or XML/XHTML syntax will be used.</p>
232 <p>The default is changed to omitting any FPI,
233 on the grounds that no FPI is better than a bogus one.  If your backend
234 generates decent HTML or XHTML, set it accordingly.</p>
235 <p>If the first form is used, mod_proxy_html
236 will also clean up the HTML to the specified standard.  It cannot
237 fix every error, but it will strip out bogus elements and attributes.
238 It will also optionally log other errors at <directive
239 module="core">LogLevel</directive> Debug.</p>
240 </usage>
241 </directivesynopsis>
242
243 <directivesynopsis>
244 <name>ProxyHTMLFixups</name>
245 <description>Fixes for simple HTML errors.</description>
246 <syntax>ProxyHTMLFixups <var>[lowercase] [dospath] [reset]</var></syntax>
247 <contextlist><context>server config</context>
248 <context>virtual host</context><context>directory</context>
249 </contextlist>
250 <compatibility>Version 2.4 and later; available as a third-party
251 for earlier 2.x versions</compatibility>
252 <usage>
253 <p>This directive takes one to three arguments as follows:</p>
254 <ul>
255 <li><code>lowercase</code> Urls are rewritten to lowercase</li>
256 <li><code>dospath</code> Backslashes in URLs are rewritten to forward slashes.</li>
257 <li><code>reset</code> Unset any options set at a higher level in the configuration.</li>
258 </ul>
259 <p>Take care when using these.  The fixes will correct certain authoring
260 mistakes, but risk also erroneously fixing links that were correct to start with.
261 Only use them if you know you have a broken backend server.</p> 
262 </usage>
263 </directivesynopsis>
264
265 <directivesynopsis>
266 <name>ProxyHTMLExtended</name>
267 <description>Determines whether to fix links in inline scripts, stylesheets,
268 and scripting events.</description>
269 <syntax>ProxyHTMLExtended <var>On|Off</var></syntax>
270 <contextlist><context>server config</context>
271 <context>virtual host</context><context>directory</context>
272 </contextlist>
273 <compatibility>Version 2.4 and later; available as a third-party
274 for earlier 2.x versions</compatibility>
275 <usage>
276 <p>Set to <code>Off</code>, HTML links are rewritten according
277 <directive>ProxyHTMLURLMap</directive> directives, but links appearing
278 in Javascript and CSS are ignored.</p>
279 <p>Set to <code>On</code>, all scripting events and embedded scripts or
280 stylesheets are also processed by the <directive>ProxyHTMLURLMap</directive>
281 rules, according to the flags set for each rule.  Since this requires more
282 parsing, performance will be best if you only enable it when strictly necessary.</p>
283 </usage>
284 </directivesynopsis>
285
286 <directivesynopsis>
287 <name>ProxyHTMLStripComments</name>
288 <description>Determines whether to strip HTML comments.</description>
289 <syntax>ProxyHTMLStripComments <var>On|Off</var></syntax>
290 <contextlist><context>server config</context>
291 <context>virtual host</context><context>directory</context>
292 </contextlist>
293 <compatibility>Version 2.4 and later; available as a third-party
294 for earlier 2.x versions</compatibility>
295 <usage>
296 <p>This directive will cause mod_proxy_html to strip HTML comments.
297 Note that this will also kill off any scripts or styles embedded in
298 comments (a bogosity introduced in 1995/6 with Netscape 2 for the
299 benefit of then-older browsers, but still in use today).
300 It may also interfere with comment-based processors such as SSI or ESI:
301 be sure to run any of those <em>before</em> mod_proxy_html in the
302 filter chain if stripping comments!</p>
303 </usage>
304 </directivesynopsis>
305
306 <directivesynopsis>
307 <name>ProxyHTMLBufSize</name>
308 <description>Sets the buffer size increment for buffering inline scripts and
309 stylesheets.</description>
310 <syntax>ProxyHTMLBufSize <var>bytes</var></syntax>
311 <contextlist><context>server config</context>
312 <context>virtual host</context><context>directory</context>
313 </contextlist>
314 <compatibility>Version 2.4 and later; available as a third-party
315 for earlier 2.x versions</compatibility>
316 <usage>
317 <p>In order to parse non-HTML content (stylesheets and scripts), mod_proxy_html
318 has to read the entire script or stylesheet into a buffer.  This buffer will
319 be expanded as necessary to hold the largest script or stylesheet in a page,
320 in increments of [nnnn] as set by this directive.</p>
321 <p>The default is 8192, and will work well for almost all pages.  However,
322 if you know you're proxying a lot of pages containing stylesheets and/or
323 scripts bigger than 8K (that is, for a single script or stylesheet,
324 NOT in total), it will be more efficient to set a larger buffer
325 size and avoid the need to resize the buffer dynamically during a request.
326 </p>
327 </usage>
328 </directivesynopsis>
329
330 <directivesynopsis>
331 <name>ProxyHTMLEvents</name>
332 <description>Specify attributes to treat as scripting events.</description>
333 <syntax>ProxyHTMLEvents <var>attribute [attribute ...]</var></syntax>
334 <contextlist><context>server config</context>
335 <context>virtual host</context><context>directory</context>
336 </contextlist>
337 <compatibility>Version 2.4 and later; available as a third-party
338 for earlier 2.x versions</compatibility>
339 <usage>
340 <p>Specifies one or more attributes to treat as scripting events and
341 apply <directive>ProxyHTMLURLMap</directive>s to where appropriate.
342 You can specify any number of attributes in one or more
343 <code>ProxyHTMLEvents</code> directives.</p>
344 <p>The default configuration defines the events in standard HTML 4
345 and XHTML 1.</p>
346 </usage>
347 </directivesynopsis>
348
349 <directivesynopsis>
350 <name>ProxyHTMLLinks</name>
351 <description>Specify HTML elements that have URL attributes to be rewritten.</description>
352 <syntax>ProxyHTMLLinks <var>element attribute [attribute2 ...]</var></syntax>
353 <contextlist><context>server config</context>
354 <context>virtual host</context><context>directory</context>
355 </contextlist>
356 <compatibility>Version 2.4 and later; available as a third-party
357 for earlier 2.x versions</compatibility>
358 <usage>
359 <p>Specifies elements that have URL attributes that should be rewritten
360 using standard <directive>ProxyHTMLURLMap</directive>s.  You will need one
361 ProxyHTMLLinks directive per element, but it can have any number of attributes.</p>
362 <p>The default configuration defines the HTML links for standard HTML 4
363 and XHTML 1.</p>
364 </usage>
365 </directivesynopsis>
366
367 <directivesynopsis>
368 <name>ProxyHTMLCharsetOut</name>
369 <description>Specify a charset for mod_proxy_html output.</description>
370 <syntax>ProxyHTMLCharsetOut <var>Charset | *</var></syntax>
371 <contextlist><context>server config</context>
372 <context>virtual host</context><context>directory</context>
373 </contextlist>
374 <compatibility>Version 2.4 and later; available as a third-party
375 for earlier 2.x versions</compatibility>
376 <usage>
377 <p>This selects an encoding for mod_proxy_html output.  It should not
378 normally be used, as any change from the default <code>UTF-8</code>
379 (Unicode - as used internally by libxml2) will impose an additional
380 processing overhead.  The special token <code>ProxyHTMLCharsetOut *</code>
381 will generate output using the same encoding as the input.</p>
382 <p>Note that this relies on <module>mod_xml2enc</module> being loaded.</p>
383 </usage>
384 </directivesynopsis>
385
386
387
388 </modulesynopsis>
389