Remove <info> from ref entry header
[metaproxy-moved-to-github.git] / doc / http_rewrite.xml
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">
5      %idcommon;
6 ]>
7 <refentry id="ref-http_rewrite">
8  <refentryinfo>
9   <productname>Metaproxy</productname>
10   <orgname>Index Data</orgname>
11  </refentryinfo>
12
13  <refmeta>
14   <refentrytitle>http_rewrite</refentrytitle>
15   <manvolnum>3mp</manvolnum>
16   <refmiscinfo>Metaproxy Module</refmiscinfo>
17  </refmeta>
18
19  <refnamediv>
20   <refname>http_rewrite</refname>
21   <refpurpose>Module for rewriting HTTP content and headers</refpurpose>
22  </refnamediv>
23
24  <refsect1><title>DESCRIPTION</title>
25   <para>
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
29    respectively.
30   </para>
31   <para>
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.
35   </para>
36   <para>
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
43    request section.
44   </para>
45   <para>
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).
54   </para>
55   <para>
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
60    with the name given.
61   </para>
62   <para>
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.
67   </para>
68   <para>
69    For "quoted-literal" content, the within element takes only a
70    "rule" attribute and the rule is performed on all content.
71   </para>
72  </refsect1>
73
74  <refsect1><title>SCHEMA</title>
75    <literallayout><xi:include
76                      xi:href="../xml/schema/filter_http_rewrite.rnc"
77                      xi:parse="text"
78                      xmlns:xi="http://www.w3.org/2001/XInclude" />
79    </literallayout>
80  </refsect1>
81
82  <refsect1><title>EXAMPLES</title>
83   <para>
84    Configuration:
85    <screen><![CDATA[
86    <filter type="http_rewrite">
87      <request>
88        <!-- save pxhost and pxpath for later -->
89        <rule name="url">
90          <rewrite
91             from='(?&lt;proto>https?://)(?&lt;pxhost>[^ /?#]+)/(?&lt;pxpath>[^ /]+)/(?&lt;host>[^ /]+)(?&lt;path>[^ ]*)'
92             to='${proto}${host}${path}' />
93          <rewrite from='(?:Host: )(.*)' to='Host: ${host}' />
94        </rule>
95        <content type="headers">
96          <within reqline="1" rule="url"/>
97        </content>
98      </request>
99      <response>
100        <!-- rewrite "back" - using pxhost and pxpath -->
101        <rule name="url">
102          <rewrite
103            from='(?&lt;proto>https?://)(?&lt;host>[^/?# &quot;&apos;>]+)/(?&lt;path>[^  &quot;&apos;>]+)'
104            to='${proto}${pxhost}/${pxpath}/${host}/${path}' />
105        </rule>
106        <content type="headers"
107          <within header="link" rule="url"/>
108        </content>
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"/>
113        </content>
114      </response>
115    </filter>
116 ]]>
117    </screen>
118   </para>
119  </refsect1>
120
121  <refsect1><title>SEE ALSO</title>
122   <para>
123    <citerefentry>
124     <refentrytitle>metaproxy</refentrytitle>
125     <manvolnum>1</manvolnum>
126    </citerefentry>
127   </para>
128  </refsect1>
129
130  &copyright;
131 </refentry>
132
133 <!-- Keep this comment at the end of the file
134 Local variables:
135 mode: nxml
136 nxml-child-indent: 1
137 End:
138 -->