[Seaside] ProxyPass and the P Option

Ramon Leon ramon.leon at allresnet.com
Tue Nov 6 17:26:35 UTC 2007


> I guess I can do something like this:
> 
> <VirtualHost 192.168.1.101:443>
> RewriteEngine       on
> ProxyRequests       off
> ProxyPreserveHost   on
> SSLEngine           on
> SSLCertificateFile  /etc/apache2/ssl/apache.pem
> DocumentRoot        /var/www/ssl
> ProxyPass           /seaside/go  balancer://seaside_cluster
> stickysession=MYCOOKIE  nofailover=on
> ProxyPassReverse    /seaside/go  balancer://seaside_cluster
> <Proxy balancer://seaside_cluster>
>     BalancerMember  http://localhost:9090/seaside/go  route=A_
>     BalancerMember  http://localhost:9091/seaside/go  route=B_
>     BalancerMember  http://localhost:9092/seaside/go  
> route=C_ </Proxy> RewriteRule  ^/$  
> balancer://seaside_cluster [P,L] </VirtualHost>
> 
> 
> Apparently, the format of the cookie name is something like 
> 'somename.someroute'. I think in the above example, somename 
> would be MYCOOKIE and someroute would be A_ or B_ or C_. Am I 
> understanding correctly?
> 
> But do I need to setup cookies in Seaside? If so, do I need 
> to setup the cookie name format, as well? If so, how?
> 
> Thanks,
> Richard

Have Seaside write out the image name in a cookie as the last step in your
initial request (making sure to grab any state you need first).

initialRequest: aRequest 
    self parseAnyNeededParams: aRequest.

    (self session currentRequest cookieAt: #server) 
        ifNil: [self session redirectWithCookie: 
            (WACookie 
                key: #server 
                value: 'seaside.', 
                    ((SmalltalkImage current imageName copyAfterLast: 
                        FileDirectory slash asCharacter) copyUpToLast:
$.))].

And configure your cluster with the route=imageName

<Proxy balancer://seaside_cluster>
    BalancerMember  http://localhost:3001/seaside  route=imageName1
    BalancerMember  http://localhost:3002/seaside  route=imageName2
</Proxy> 

ProxyPass /seaside/files balancer://seaside_cluster/files
lbmethod=byrequests stickysession=server
ProxyPass / balancer://seaside_cluster/ lbmethod=byrequests
stickysession=server
ProxyPassReverse / balancer://seaside_cluster/

Tell Apache what the cookie name is and it will have what it needs to parse
the cookie and route to the correct image.  I couldn't get this working last
time I tried but I was missing the information about the "." Apache was
expecting in the cookie, I chose HAProxy instead.  Now that this works, I
might have to switch back to Apache for load balancing, very nice!  Found
what I needed in
http://www.markround.com/archives/33-Apache-mod_proxy-balancing-with-PHP-sti
cky-sessions.html

Ramon Leon
http://onsmalltalk.com  



More information about the seaside mailing list