Forum Discussion
Christopher_Hyl
May 05, 2011Nimbostratus
True-IP persistence or source-IP if it doesn't exsist.
This is a basic derivative of the irule in the last post .
It's a long story of why we're doing this, but we're using a CDN that passes us the "true-client-ip" HTTP header. We want source persistence to our pool with this variable, but sometimes we get traffic that will not be from the CDN. We want source-ip based persistence to our back-end pool in these cases.
Will this do the trick? Is there a more efficient/better way?
when HTTP_REQUEST {
if {[HTTP::header exists "True-Client-IP"]}{
set tcip_header [HTTP::header "True-Client-IP"]
} else { set tcip_header [IP::remote_addr] }
if {[active_members Onlinebrands_http_real_server]}{
if {[scan [lindex [active_members –list app_http_pool] [expr {[md5 $tcip_header] % [active_members app_http_pool]}]] {%s %s} ip port] == 2}{
pool app_http_pool member $ip $port
return
}
}
}
- hooleylistCirrostratusHi Christopher,
- Christopher_HylNimbostratusHi Aaron,
- Christopher_HylNimbostratusActually, this one would be better as it grabs the pool that's assigned to the VIP and I can now be used across multiple VIPs with a single irule. This should help users like me who use CDNs like akamai or limelight.
when HTTP_REQUEST { set default_pool [LB::server pool] if {[HTTP::header exists "True-Client-IP"]}{ set tcip_header [HTTP::header "True-Client-IP"] } else { set tcip_header [IP::remote_addr] } if {[active_members $default_pool]}{ persist uie $tcip_header 43200 return } }
- Colin_Walker_12Historic F5 AccountJust keep in mind that LB::server will only return info about the default pool, or after an LB decision. It looks like it should be fine where you're using it, but it gets some people into trouble thinking they can use it to tell information about the server that's going to be chosen, which isn't how it works.
- Christopher_HylNimbostratusColin,
- Colin_Walker_12Historic F5 AccountCool, it didn't look like it mattered in your scenario but I figured as a word of warning for others reading it wouldn't hurt. ;)
- Christopher_HylNimbostratusHmmm, it doesn't look like it's working on our test website. It's not even falling back to source persistence. Am I supposed to be checking if a persistence profile already exists before assigning one in the variable? Am I clobbering already existing persistence assignments? Should I be doing what they're doing here:
when HTTP_REQUEST { Check if there is an existing UIE persistence record if {[persist lookup uie "[IP::client_addr]_apps"] ne ""}{ Use the existing UIE persistence record regardless of which URI was requested persist uie "[IP::client_addr]_apps"] 36000 } else { Check requested path switch -glob [HTTP::path] { "/apps/aml/*" { Persist client for 10 hours using client IP _ apps persist uie "[IP::client_addr]_apps" 36000 } default { Persist client for 1 hour persist source_addr 3600 } } } }
- Christopher_HylNimbostratusOr maybe I need to enable Universal persistence? I assumed that the irule was enough... (sorry, I'm new to irules!).
- hooleylistCirrostratusYou don't need a UIE persistence profile if you're setting the timeout in the persist command in the rule and don't need to use the match across or mirror options of the UIE profile.
- Christopher_HylNimbostratusI've attached the irule to the persistence profile and the persistence profile to the VIP, but it's still not working. It seems to be passing them almost round-robin.
May 6 12:24:21 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:21 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:21 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:23 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:24 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:24 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:24 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:24 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:26 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:26 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:26 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:26 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:26 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:28 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:29 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:29 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:29 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:29 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:31 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:31 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:31 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:31 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:31 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:33 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:34 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.179 May 6 12:24:34 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:34 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:34 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:36 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181 May 6 12:24:36 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.182 May 6 12:24:36 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:36 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:36 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.180 May 6 12:24:38 tmm tmm[1715]: Rule persistenceiRule : HTTP setting persist to: 1.2.3.4 CDN-IP: 208.111.181.181
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