Раздел 10. Apache modules Пункты: 85 86 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 RU EN Пункт 178. Apache Module mod_proxy_html
SummaryThis 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. For example, if a company has an application server at
mod_proxy_html was originally developed at WebЮing, whose extensive documentation may be useful to users. ProxyHTMLBufSize Directive
In order to parse non-HTML content (stylesheets and scripts) embedded in HTML documents, mod_proxy_html has to read the entire script or stylesheet into a buffer. This buffer will be expanded as necessary to hold the largest script or stylesheet in a page, in increments of bytes as set by this directive. The default is 8192, and will work well for almost all pages. However, if you know you're proxying pages containing stylesheets and/or scripts bigger than 8K (that is, for a single script or stylesheet, NOT in total), it will be more efficient to set a larger buffer size and avoid the need to resize the buffer dynamically during a request. ProxyHTMLCharsetOut Directive
This selects an encoding for mod_proxy_html output. It should not
normally be used, as any change from the default Note that this relies on ProxyHTMLDocType Directive
In the first form, documents will be declared as HTML 4.01 or XHTML 1.0 according to the option selected. This option also determines whether HTML or XHTML syntax is used for output. Note that the format of the documents coming from the backend server is immaterial: the parser will deal with it automatically. If the optional second argument is set to "Legacy", documents will be declared "Transitional", an option that may be necessary if you are proxying pre-1998 content or working with defective authoring/publishing tools. In the second form, it will insert your own FPI. The optional second argument determines whether SGML/HTML or XML/XHTML syntax will be used. The default is changed to omitting any FPI, on the grounds that no FPI is better than a bogus one. If your backend generates decent HTML or XHTML, set it accordingly. If the first form is used, mod_proxy_html
will also clean up the HTML to the specified standard. It cannot
fix every error, but it will strip out bogus elements and attributes.
It will also optionally log other errors at ProxyHTMLEnable Directive
A simple switch to enable or disable the proxy_html filter.
If Note that the proxy_html filter will only act on HTML data (Content-Type text/html or application/xhtml+xml) and when the data are proxied. You can override this (at your own risk) by setting the PROXY_HTML_FORCE environment variable. ProxyHTMLEvents Directive
Specifies one or more attributes to treat as scripting events and
apply Normally you'll set this globally. If you set ProxyHTMLEvents in more than one scope so that one overrides the other, you'll need to specify a complete set in each of those scopes. A default configuration is supplied in proxy-html.conf and defines the events in standard HTML 4 and XHTML 1. ProxyHTMLExtended Directive
Set to Set to
You'll also need to take care over patterns matched, since the parser has no
knowledge of what is a URL within an embedded script or stylesheet.
In particular, extended matching of ProxyHTMLFixups Directive
This directive takes one to three arguments as follows:
Take care when using these. The fixes will correct certain authoring mistakes, but risk also erroneously fixing links that were correct to start with. Only use them if you know you have a broken backend server. ProxyHTMLInterp Directive
This enables per-request interpolation in
If interpolation is not enabled, all rules are pre-compiled at startup. With interpolation, they must be re-compiled for every request, which implies an extra processing overhead. It should therefore be enabled only when necessary. ProxyHTMLLinks Directive
Specifies elements that have URL attributes that should be rewritten
using standard Normally you'll set this globally. If you set ProxyHTMLLinks in more than one scope so that one overrides the other, you'll need to specify a complete set in each of those scopes. A default configuration is supplied in proxy-html.conf and defines the HTML links for standard HTML 4 and XHTML 1. Examples from proxy-html.confProxyHTMLLinks a href ProxyHTMLLinks area href ProxyHTMLLinks link href ProxyHTMLLinks img src longdesc usemap ProxyHTMLLinks object classid codebase data usemap ProxyHTMLLinks q cite ProxyHTMLLinks blockquote cite ProxyHTMLLinks ins cite ProxyHTMLLinks del cite ProxyHTMLLinks form action ProxyHTMLLinks input src usemap ProxyHTMLLinks head profile ProxyHTMLLinks base href ProxyHTMLLinks script src for ProxyHTMLMeta Directive
This turns on or off pre-parsing of metadata in HTML
If not required, turning ProxyHTMLMeta Off will give a small performance boost by skipping this parse step. However, it is sometimes necessary for internationalisation to work correctly. ProxyHTMLMeta has two effects. Firstly and most importantly it enables detection of character encodings declared in the form <meta http-equiv="Content-Type" content="text/html;charset=foo"> or, in the case of an XHTML document, an XML declaration.
It is NOT required if the charset is declared in a real HTTP header
(which is always preferable) from the backend server, nor if the
document is utf-8 (unicode) or a subset such as ASCII.
You may also be able to dispense with it where documents use a
default declared using The other effect of enabling ProxyHTMLMeta is to parse all
WarningBecause ProxyHTMLMeta promotes all http-equiv elements to HTTP headers, it is important that you
only enable it in cases where you trust the HTML content as much as you
trust the upstream server. If the HTML is controlled by bad actors, it
will be possible for them to inject arbitrary, possibly malicious, HTTP
headers into your server's responses.
ProxyHTMLStripComments Directive
This directive will cause mod_proxy_html to strip HTML comments. Note that this will also kill off any scripts or styles embedded in comments (a bogosity introduced in 1995/6 with Netscape 2 for the benefit of then-older browsers, but still in use today). It may also interfere with comment-based processors such as SSI or ESI: be sure to run any of those before mod_proxy_html in the filter chain if stripping comments! ProxyHTMLURLMap Directive
This is the key directive for rewriting HTML links. When parsing a document,
whenever a link target matches from-pattern, the matching
portion will be rewritten to to-pattern, as modified by any
flags supplied and by the
The optional third argument may define any of the following Flags. Flags are case-sensitive.
The optional fourth cond argument defines a condition
that will be evaluated per Request, provided
A cond is evaluated by the Expression Parser. In addition, the simpler syntax of conditions in mod_proxy_html 3.x for HTTPD 2.0 and 2.2 is also supported. Пункты: 85 86 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 163 164 165 166 167 168 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 203 204 205 206 207 208 209 210 211 212 213 |