1 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.4//EN"
2 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
3 <!ENTITY copyright SYSTEM "copyright.xml">
4 <!ENTITY % idcommon SYSTEM "common/common.ent">
7 <refentry id="ref-http_rewrite">
9 <productname>Metaproxy</productname>
10 <orgname>Index Data</orgname>
14 <refentrytitle>http_rewrite</refentrytitle>
15 <manvolnum>3mp</manvolnum>
16 <refmiscinfo>Metaproxy Module</refmiscinfo>
20 <refname>http_rewrite</refname>
21 <refpurpose>Module for rewriting HTTP content and headers</refpurpose>
24 <refsect1><title>DESCRIPTION</title>
26 The primary purpose of this module is to rewrite links (URLs) for
27 proxying. The configuration is divided in two sections:
28 request and response for dealing with the HTTP request and response
32 Each section consists of rule and content elements. Each rule must be
33 given a name (attribute "name") and these are referred to from
34 content elements. The content defines what rules are invoked.
37 Each rule consists of one or more rewrite elements. The rewrite
38 specifies a regular expression for matching content in the attribute
39 "from" and the corresponding attribute "from" specifies the result.
40 The "to" result may refer to named groups in any "from" pattern already
41 executed. For example, in the response section a rule may refer to both
42 groups in the response already executed and all rules exectuted in the
46 Each content section takes exactly one "type" attribute, which specifies
47 what area is inspected for rewriting. Type may be one of
48 "html" (for HTML content), "headers" for HTTP headers or
49 "quoted-literal" for Java Script type of content.
50 The content section takes one or more "within" elements. That specifies
51 where inside the content, each rule is being exectuted. All within
52 must have a "rule" attribtue that specifies the rule section to be
53 invoked (rule@name as mentioned earlier).
56 For "html" content, the within element takes also attributes "tag"
57 and "attr",that specifies tag and attributes to be inspected.
58 The attr attributes takes one or more attributes (comma separated).
59 If no "tag" is given, the rule is performed on all attributes
63 For "headers" content the within element takes "header" or "reqline" +
64 the "rule" attribute. For "header", the rule is performed on all
65 HTTP headers with the name in header. For "reqline", the
66 HTTP Request line is rewritten.
69 For "quoted-literal" content, the within element takes only a
70 "rule" attribute and the rule is performed on all content.
74 <refsect1><title>SCHEMA</title>
75 <literallayout><xi:include
76 xi:href="../xml/schema/filter_http_rewrite.rnc"
78 xmlns:xi="http://www.w3.org/2001/XInclude" />
82 <refsect1><title>EXAMPLES</title>
86 <filter type="http_rewrite">
88 <!-- save pxhost and pxpath for later -->
91 from='(?<proto>https?://)(?<pxhost>[^ /?#]+)/(?<pxpath>[^ /]+)/(?<host>[^ /]+)(?<path>[^ ]*)'
92 to='${proto}${host}${path}' />
93 <rewrite from='(?:Host: )(.*)' to='Host: ${host}' />
95 <content type="headers">
96 <within reqline="1" rule="url"/>
100 <!-- rewrite "back" - using pxhost and pxpath -->
103 from='(?<proto>https?://)(?<host>[^/?# "'>]+)/(?<path>[^ "'>]+)'
104 to='${proto}${pxhost}/${pxpath}/${host}/${path}' />
106 <content type="headers"
107 <within header="link" rule="url"/>
109 <content type="html">
110 <within tag="script" attr="#text" type="quoted-literal" rule="url"/>
111 <within attr="href,src" rule="url"/>
112 <within attr="onclick" type="quoted-literal" rule="url"/>
121 <refsect1><title>SEE ALSO</title>
124 <refentrytitle>metaproxy</refentrytitle>
125 <manvolnum>1</manvolnum>
133 <!-- Keep this comment at the end of the file