Mixing RewriteRule and ProxyPass in Apache
Looks like I can use the ProxySet directive so the URL's that match the RewriteRule load balance in the same fashion.
<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
ProxySet stickysession=JSESSIONID|jsessionid scolonpathdelim=On lbmethod=bytraffic nofailover=Off
</Proxy>
Taylor Leese
I herd cats and make services scale -- sometimes at the same time.
Updated on June 17, 2022Comments
-
Taylor Leese almost 2 years
I was working on debugging an issue today related to mixing
mod_proxy
andmod_rewrite
together and I ended up having to usebalancer://mycluster
in theRewriteRule
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 theRewriteRule
?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>
orRewriteRule
? I'm concerned the requests that match the newRewriteRule
won't load balance in the same fashion as those that go throughProxyPass
(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]