Skip to content

Commit 5628349

Browse files
committed
rewrite guide: merge proxy.xml content into avoid.xml, replace proxy.xml with deprecation stub (BZ 58892, step 5)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1933622 13f79535-47bb-0310-9956-ffa450edef68
1 parent a546c38 commit 5628349

2 files changed

Lines changed: 25 additions & 71 deletions

File tree

docs/manual/rewrite/avoid.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ other <code>RewriteRule</code>s in effect in the same scope, as a
189189
<code>ProxyPass</code>, and so may preempt what you're trying to
190190
accomplish.</p>
191191

192+
<p>One case where <directive module="mod_rewrite">RewriteRule</directive>
193+
is genuinely useful for proxying is when you want to proxy requests only
194+
for content that doesn't exist locally — for example, during a migration
195+
from one server to another:</p>
196+
197+
<highlight language="config">
198+
RewriteCond "%{REQUEST_FILENAME}" !-f
199+
RewriteCond "%{REQUEST_FILENAME}" !-d
200+
RewriteRule "^/(.*)" "http://old.example.com/$1" [P]
201+
ProxyPassReverse "/" "http://old.example.com/"
202+
</highlight>
203+
204+
<p>In this example, requests for resources that haven't been migrated
205+
yet are transparently proxied to the old server. As content is migrated,
206+
the local files take precedence. Remember to always include a
207+
<directive module="mod_proxy">ProxyPassReverse</directive> directive to
208+
ensure that any redirects issued by the backend are correctly passed on
209+
to the client.</p>
210+
192211
</section>
193212

194213
<section id="setenv"><title>Environment Variable Testing</title>

docs/manual/rewrite/proxy.xml

Lines changed: 6 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -27,78 +27,13 @@
2727

2828
<summary>
2929

30-
<p>This document supplements the <module>mod_rewrite</module>
31-
<a href="../mod/mod_rewrite.html">reference documentation</a>. It describes
32-
how to use the RewriteRule's [P] flag to proxy content to another server.
33-
A number of recipes are provided that describe common scenarios.</p>
30+
<note type="warning">This document has been deprecated. Its content has
31+
been merged into the
32+
<a href="avoid.html#proxy">When not to use mod_rewrite</a> document,
33+
since simple proxying is better accomplished using
34+
<directive module="mod_proxy">ProxyPass</directive>. This page will be
35+
removed in a future version of this documentation.</note>
3436

3537
</summary>
36-
<seealso><a href="../mod/mod_rewrite.html">Module documentation</a></seealso>
37-
<seealso><a href="intro.html">mod_rewrite introduction</a></seealso>
38-
<seealso><a href="remapping.html">Redirection and remapping</a></seealso>
39-
<seealso><a href="access.html">Controlling access</a></seealso>
40-
<seealso><a href="vhosts.html">Virtual hosts</a></seealso>
41-
<!--<seealso><a href="proxy.html">Proxying</a></seealso>-->
42-
<seealso><a href="rewritemap.html">Using RewriteMap</a></seealso>
43-
<seealso><a href="advanced.html">Advanced techniques</a></seealso>
44-
<seealso><a href="avoid.html">When not to use mod_rewrite</a></seealso>
45-
46-
<section id="dynamic-proxy">
47-
48-
<title>Proxying Content with mod_rewrite</title>
49-
50-
<dl>
51-
<dt>Description:</dt>
52-
53-
<dd>
54-
<p>
55-
<module>mod_rewrite</module> provides the [P] flag, which allows URLs to be passed,
56-
via <module>mod_proxy</module>, to another server. Two examples are given here. In
57-
one example, a URL is passed directly to another server, and served
58-
as though it were a local URL. In the other example, we proxy
59-
missing content to a back-end server.</p>
60-
</dd>
61-
62-
<dt>Solution:</dt>
63-
64-
<dd>
65-
<p>To simply map a URL to another server, we use the [P] flag, as
66-
follows:</p>
67-
68-
<highlight language="config">
69-
RewriteEngine on
70-
RewriteBase "/products/"
71-
RewriteRule "^widget/(.*)$" "http://product.example.com/widget/$1" [P]
72-
ProxyPassReverse "/products/widget/" "http://product.example.com/widget/"
73-
</highlight>
74-
75-
<p>In the second example, we proxy the request only if we can't find
76-
the resource locally. This can be very useful when you're migrating
77-
from one server to another, and you're not sure if all the content
78-
has been migrated yet.</p>
79-
80-
<highlight language="config">
81-
RewriteCond "%{REQUEST_FILENAME}" !-f
82-
RewriteCond "%{REQUEST_FILENAME}" !-d
83-
RewriteRule "^/(.*)" "http://old.example.com/$1" [P]
84-
ProxyPassReverse "/" "http://old.example.com/"
85-
</highlight>
86-
</dd>
87-
88-
<dt>Discussion:</dt>
89-
90-
<dd><p>In each case, we add a <directive
91-
module="mod_proxy">ProxyPassReverse</directive> directive to ensure
92-
that any redirects issued by the backend are correctly passed on to
93-
the client.</p>
94-
95-
<p>Consider using either <directive
96-
module="mod_proxy">ProxyPass</directive> or <directive
97-
module="mod_proxy">ProxyPassMatch</directive> whenever possible in
98-
preference to <module>mod_rewrite</module>.</p>
99-
</dd>
100-
</dl>
101-
102-
</section>
10338

10439
</manualpage>

0 commit comments

Comments
 (0)