I got this working with mod_jk and the following configuration for
mod_rewrite:

RewriteEngine On

# http://domain/?v=1 --> http://domain/app1/?v=1
RewriteCond     %{QUERY_STRING}     v=([^&]+)
RewriteRule     ^(.*)$              /app%1/$1 [L]

# http://domain --> http://domain/app (default ROOT in Tomcat)
RewriteRule     ^$                  /app/ [L]

My mod_jk configuration is:

JkMount /app* loadbalancer

I tried to use mod_proxy and mod_proxy_ajp, but for some reason (with Apache
2.2.4 on OS X), I couldn't get the following to work (from httpd.conf):

<Proxy balancer://cluster>
    BalancerMember ajp://localhost:8009 route=tomcat1
    BalancerMember ajp://localhost:8010 route=tomcat2
</Proxy>

<Location ~ /app(.*)>
    Order Allow,Deny
    Allow from all
    ProxyPass balancer://cluster stickysession=JSESSIONID
    ProxyPassReverse /
</Location>

I tried LocationMatch as well, but no dice. Something about my configuration
doesn't seem to allow Location|LocationMatch to read the regular expressions
properly.

The nice thing about using mod_proxy is I could use mod_proxy_html to
rewrite all the outgoing links so they're the same as the incoming links
(notice my mod_rewrite configuration does not do redirects).

The problem I'm trying to solve now is how to round-robin between apps 1, 2
and 3.  If there's a "v" parameter or "v" cookie, I want to disable
round-robin-ing.  But otherwise, I want to assign an app so all the A/B
tests are used equally by anonymous users.

Matt

press wrote:
> 
> Hi Matt, See configuration below.  I hope this helps you - Clay
> 
> Test Cases for Requirement #1
> http://www.domain.com/?v=1                                    ->
> http://www.domain.com/1
> http://www.domain.com/?v=2                                    ->
> http://www.domain.com/2
> 
> Test Cases for Requirement #2
> http://www.domain.com/?q=foo&v=1                     ->
> http://www.domain.com/1
> http://www.domain.com/?v=1&q=foo                     ->
> http://www.domain.com/1
> http://www.domain.com/?p=bar&v=1&q=foo         -> http://www.domain.com/1
> 
> #mod_proxy_ajp, mod_proxy_balancer and mod_rewrite configuration
> 
> #webapp1 or webapp2 are deployed
> RewriteCond    %{QUERY_STRING}          (.*)v=(1|2)      
> RewriteRule     ^(.*)$                                 /%2/? [L,R]
> 
> #default to webapp1  for anything else
> RewriteCond    %{QUERY_STRING}           (.*)v=([^12])    
> RewriteRule     ^(.*)$                                 /1/?   [L,R]
> 
> 
> <Proxy balancer://cluster >
>     BalancerMember ajp://localhost:8009 route=tomcat1 
>     #BalancerMember ajp://localhost:8010 route=tomcat2
> </Proxy>
> 
> <Location /1 >
>     ProxyPass balancer://cluster/servlets-examples
> </Location>
> 
> <Location /2 >
>     ProxyPass balancer://cluster/jsp-examples
> </Location>
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Mixing-Apache%27s-mod_rewrite-with-mod_proxy-tf3587361.html#a10063745
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to