Forum Discussion

Christopher_Hyl's avatar
Christopher_Hyl
Icon for Nimbostratus rankNimbostratus
May 05, 2011

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

 

}

 

}

 

}