Forum Moderators: phranque

Message Too Old, No Replies

What is best practice ProxyPass, Rewrite, Redirect

Proxy or Redirect?

         

dmwaff

5:29 am on Jul 8, 2009 (gmt 0)

10+ Year Member




The application team is changing some functionality. Certain REQUEST_URI's are now going to be served by a new downstream JAVA application.

Should I redirect or proxy? I know mod_rewrite should NOT be used unless there is no other way. They configured #1 in our lower environments. I am config code reviewing for QA/PROD and I think what they have done is bad. It can be served by #2 or #3.

1) RewriteRule ^/travel/itinerary.html$ /a/res.html [R,L]

2) <Location /travel/itinerary.html>
ProxyPass balancer://cluster/a/res.html
ProxyPassReverse balancer://cluster/a/res.html
</Location>

3) Redirect 302 /travel/itinerary.html /a/res.html

Is proxying (#2) the best practice solution? Redirect (#3) would generate another client HTTP request and double request traffic, right?

Later on down in the conf they have placed the following to pick up the #1 /a rewrite REDIRECT and send down stream to the new backend app. This is also required if I use #3 too.

RewriteRule ^/a(/)?$ balancer://cluster%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/a/(.*)$ balancer://cluster%{REQUEST_URI} [P,QSA,L]

So I could proxy it directly OR instruct it using a Redirect directive, which the above RewriteRule will match and proxy anyway.

thoughts?
Cheers,
D

Caterham

9:38 am on Jul 8, 2009 (gmt 0)

10+ Year Member



and I think what they have done is bad.

+1

For a simple redirect, use the redirect directive provided by mod_alias, unless you've a conflict with other RewriteRules.

Later on down in the conf they have placed the following to pick up the #1 /a rewrite REDIRECT and send down stream to the new backend app.

That is a pretty good example that people tend to use mod_rewrite for everything, if necessary or not. Use the ProxyPass and/or ProxyPassMatch directive(s) provided by mod_proxy but not a RewriteRule to turn such a simple request into a reverse proxy.

So I could proxy it directly OR instruct it using a Redirect directive, which the above RewriteRule will match and proxy anyway.

That depends upon what you want. Do you want to tell the client that /travel/itinerary.html has moved temporarily to /a/res.html or not?

jdMorgan

1:10 pm on Jul 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Certain REQUEST_URI's are now going to be served by a new downstream JAVA application.

Use the ProxyPass and/or ProxyPassMatch directive(s) provided by mod_proxy [...]

Yes. This is the 'standard implementation' used by almost everyone to support back-end applications.

Jim