Forum Discussion

Ted_Smith_11168's avatar
Ted_Smith_11168
Icon for Nimbostratus rankNimbostratus
Aug 03, 2005

Help in creating DataCenter Persistance with iRule

Fairly new to iRule so looking for some help on an idea.

 

 

www.companya.com is a WideIP on a 3dns server that resolves to addresses 10.0.0.1 or 11.0.0.1. Each address goes to a different DataCenter (we'll call them 1 and 2). I don't care which Datacenter the client lands on, but once there I want them to stick.

 

 

Once connected to a DC, I thought I could do a redirect to a DNS name that only resided on that paticular DC. For example, connecting to DC1, I would redirect to www1.companya.com. The DNS address of www1.companya.com would always be in DC1. DC2 would redirect to www2.companya.com which only resided on DC2.

 

 

I don't want anyone to directly bookmark the www1 or www2 site. I still want all initial traffic to be balanced by 3dns (in case one DC is unavailable.

 

 

On the initial VIP www.companya.com, I want to set cookie values in an iRule then re-direct to www1companya.com. The second VIP iRule (www1.companya.com) will check for these set cookie values. If they values are present let the client through to the site, If not re-direct back to www.companya.com to be loadbalanced to a DC. I think that this will keep users from bypassing the 3dns. Again the 3dns needs to pick the DC, then iRules need to stick the user to the DC.

 

 

Here's what I have so far. Please add any comments.

 

 

iRule set for www.companya.com VIP

 

when CLIENT_ACCEPTED {

 

set ckname www1

 

set ckvalue [IP::client_addr]

 

set ckdomain companya.com

 

set cookie [format "%s=%s; path=/; domain=%s" $ckname $ckvalue $ckdomain]

 

}

 

when HTTP_RESPONSE {

 

HTTP::respond 302 Location "https://www1.companya.com" "Set-Cookie" $cookie

 

}

 

 

 

iRule set for www1.companya.com VIP

 

 

when CLIENT_ACCEPTED {

 

set ckname www1

 

set ckvalue [IP::client_addr]

 

set ckdomain companya.com

 

}

 

when HTTP_REQUEST {

 

if {[HTTP::cookie exists $ckname]} {

 

pool UITShared

 

}

 

else {

 

HTTP::redirect "https://www.companya.com"

 

}

 

}

 

 

Suppose this will really work? I have not tried it yet. Ideas?

 

 

Thanks for all your help!

 

1 Reply

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Yup, looks like it should work. I do have a question though, do you really need to redirect the original request or can you simply pass it through to the correct pool of servers? This probably depends on whether or not the server returns relative or absolute uri's in it's responses or even some other application dependent thing. The nice thing about not redirecting is that the client browser will maintain the original uri and hence be unable to bookmark the endpoint server directly. However, I realize that may not be feasible with your situation and this does seem like a pretty good way to make sure the client has at least gone through the original vip.

     

    Good luck.