Forum Discussion
Stevenson_88156
Nimbostratus
Jul 04, 2010iRule Help!!
I am newbie with iRule and I am just trying out some sample codes to test out how iRule works. I started to developed a simple custom persister whereby a cookie is created to store the serverid on the response and on the request event, it would read the cookie and forward the user to the appropriate member of the pool. As shown below:
when HTTP_REQUEST { if { [HTTP::cookie exists "cookie"]}{ HTTP::cookie decrypt "cookie" "mykey" set serverid [substr [HTTP::cookie cookie] 10] log local0. "Server Persistence: $serverid" pool TestPoolA member $serverid } else { pool TestPoolA } } when HTTP_RESPONSE { log local0. "Choosen Server: [LB::server]" HTTP::cookie insert name "cookie" value [LB::server] HTTP::cookie encrypt "cookie" "mykey" }
However, when I tried to use this iRule, it wouldn't persist the client user to the chosen pool member even if the log shows the correct value. And by the third or forth connection try, the virtual server could no longer connect to the pool even when the pool is specified in the iRule.
Note that I did not have the virtual server associated to any default pool and I had also use "one connect" profiles.
Is this iRule wrong? Any comments and advise regarding this iRule would be gladly be appreciated. Thanks.
- hoolio
Cirrostratus
Hi, - Stevenson_88156
Nimbostratus
Hi, - hoolio
Cirrostratus
I couldn't remember if the pool name was included in LB::server output in HTTP_RESPONSE. If it is, as you've shown, you can use scan to parse the three fields:when HTTP_REQUEST { ...cookie decryption above Parse the pool name, IP and port from the cookie if {[scan [HTTP::cookie cookie] {%s %s %s} pool ip port] == 3}{ log loca0. "Parsed $pool $ip $port" Select the pool member pool $pool member $ip $port } else { log local0. "Couldn't parse pool, IP and port from [HTTP::cookie cookie]" } }
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