[PLUG] RewriteCond

Carlos Konstanski ckonstanski at pippiandcarlos.com
Fri Jul 8 00:28:15 UTC 2011


I did get somewhere. I abandoned RewriteRule in favor of mod_header:

<VirtualHost *:80>
    ServerName dc.pippiandcarlos.com
    ServerAdmin postmaster at pippiandcarlos.com
    ProxyPass / balancer://dc.pippiandcarlos.com.cluster/
    ProxyPassreverse / balancer://dc.pippiandcarlos.com.cluster/
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/"
env=BALANCER_ROUTE_CHANGED
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost>

And then removed all Rewrite stuff from the backend VirtualHosts. That
Header line works all the magic, but I don't understand it fully. That the
heck is the little "e" for? Oh well, it works.

Also I moved the stickysession parameter to inside the Proxy directive:

<Proxy balancer://dc.pippiandcarlos.com.cluster>
    BalancerMember http://dc1.pippiandcarlos.com route=1
    BalancerMember http://dc2.pippiandcarlos.com route=2
    ProxySet stickysession=ROUTEID
</Proxy>

Carlos

On 07/07/2011 05:51 PM, Joe Pruett wrote:
> did you get anywhere with this?
> 
> you can check the HTTP_COOKIE var in a rewritecond, so something like:
> 
> RewriteCond %{HTTP_COOKIE} !BALANCEID=
> 
> should stop processing if there is already a BALANCEID cookie set.
> 
> On 07/05/2011 11:34 PM, Carlos Konstanski wrote:
>> I'm having an issue with apache's mod_proxy_balancer. I need to set a cookie
>> in the form <something>.<routeid>. Using RewriteRule to do it. It's writing
>> the cookie fine, but it keeps REWRITING it upon every request
>> unconditionally with a new Set-Cookie. I think I need a RewriteCond to check
>> for the existence of the cookie first. Can someone help me understand how to
>> write the condition? Struggling with the docs.
>>
>> Below is my entire balancer config.
>>
>> Thanks,
>>
>> Carlos
>>
>> <VirtualHost *:80>
>>     ServerName dc.pippiandcarlos.com
>>     ServerAdmin postmaster at pippiandcarlos.com
>>     ProxyPass / balancer://dc.pippiandcarlos.com.cluster/
>> stickysession=BALANCEID
>>     SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
>> </VirtualHost>
>>
>> <Proxy balancer://dc.pippiandcarlos.com.cluster>
>>     BalancerMember http://dc1.pippiandcarlos.com/ route=dc1
>>     BalancerMember http://dc2.pippiandcarlos.com/ route=dc2
>> </Proxy>
>>
>> <VirtualHost *:80>
>>     ServerName dc1.pippiandcarlos.com
>>     ServerAdmin postmaster at pippiandcarlos.com
>>     ProxyPass / http://dc1.pippiandcarlos.com:3001/
>>     ProxyPassReverse / http://dc1.pippiandcarlos.com:3001/
>>     RewriteEngine On
>>     RewriteRule .* - [CO=BALANCEID:balancer.dc1:.pippiandcarlos.com]
>>     SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
>> </VirtualHost>
>>
>> <VirtualHost *:80>
>>     ServerName dc2.pippiandcarlos.com
>>     ServerAdmin postmaster at pippiandcarlos.com
>>     ProxyPass / http://dc2.pippiandcarlos.com:3002/
>>     ProxyPassReverse / http://dc2.pippiandcarlos.com:3002/
>>     RewriteEngine On
>>     RewriteRule .* - [CO=BALANCEID:balancer.dc2:.pippiandcarlos.com]
>>     SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
>> </VirtualHost>
>> _______________________________________________
>> PLUG mailing list
>> PLUG at lists.pdxlinux.org
>> http://lists.pdxlinux.org/mailman/listinfo/plug
>>




More information about the PLUG mailing list