Mixing RewriteRule and ProxyPass in Apache
Posted
by Taylor L
on Stack Overflow
See other posts from Stack Overflow
or by Taylor L
Published on 2009-05-18T18:58:06Z
Indexed on
2010/04/10
7:23 UTC
Read the original article
Hit count: 318
I was working on debugging an issue today related to mixing mod_proxy
and mod_rewrite
together and I ended up having to use balancer://mycluster
in the RewriteRule
in order to stop receiving a 404 error from Apache. I have two questions:
1) Is there any other way to get the rewritten URL to go through the balancer without adding balancer://mycluster
into the RewriteRule
?
2) Is there a way to define all the parameters I defined in ProxyPass
(stickysession=JSESSIONID|jsessionid scolonpathdelim=On lbmethod=bytraffic nofailover=Off) in either the <Proxy>
or RewriteRule
? I'm concerned the requests that match the new RewriteRule
won't load balance in the same fashion as those that go through ProxyPass
(like /app1/something.do
)?
Below are the relevant sections of the httpd.conf. I am using Apache 2.2.
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
BalancerMember ajp://my.domain.com:8009 route=node1
BalancerMember ajp://my.domain.com:8009 route=node2
</Proxy>
ProxyPass /app1 balancer://mycluster/app1 stickysession=JSESSIONID|jsessionid scolonpathdelim=On lbmethod=bytraffic nofailover=Off
ProxyPassReverse /app1 ajp://my.domain.com:8009/app1
...
RewriteRule ^/static/cms/image/(.*)\.(.*) balancer://mycluster/app1/$1.$2 [P,L]
© Stack Overflow or respective owner