Forum Discussion
Yekesa_Kosuru_1
Nimbostratus
Nov 15, 2006pls help
Hi All,
I am an absolute newbie, never used iRule, dont even know how to deploy this code to Big IP. Looking at examples, I created iRule, could you please tell me if this is correct.
I have a customer with Big IP deployed in front of our app. Our app is clustered and has 5 nodes. We partition the users among the 5 nodes. When a HTTP request comes in we need to send the request to an appropriate node otherwise our app wont work. So I am trying to inspect the payload, look for userid, hash the user id and figure out a node I can forward the request to. I wrote code as much as I could, your help is very much appreciated.
when HTTP_REQUEST {
if { [HTTP::method] equals "POST" } {
if { [HTTP::header exists "Content-Length"] } {
set content_length [HTTP::header "Content-Length"]
} else {
user id should be at the very beginning hopefully
set content_length 2048
}
if { $content_length > 0 } {
HTTP::collect $content_length
}
}
}
when HTTP_REQUEST_DATA {
set payload [HTTP::payload [HTTP::payload length]]
user id appears as uid=someuser@abc.com
inspect HTTP::payload for it's contents.
regexp {\([\w]+)@abc.com} $payload userid
log local0. “user id is '$userid' “
if { "" ne $userid } {
is there a hash function to call to figure out a node?
}
}
Questions :
1. Is the above code correct in what it is doing ?
2. Is there a hash function I could call to get a hash value given userid. I need a hash function that spits out a value between 1 and 5 for example so I can send hashvalues that evaluate to 1 to node 1, 2 to node 2 etc. When I say node, it is Jboss cluster node where app is running.
3. User entry in payload has this format uid=someuser@abc.com. I am interested in middle part which is someuser. Is there a better to retrieve it
4. Can I test if the node is down before sending it off to that node ? If it is down I'd like to send it to another node
5. Is there a better way to do what I am trying to do?
THANKS A LOT
5.
No RepliesBe the first to reply
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects