Forum Discussion
dani82_22742
Nimbostratus
Jan 15, 2008Redirect HTTP and HTTPS traffic to the same node in different pools
I have two pools with the same servers but with other ports. I need, that a client, which is connected with http ends on the same server, if it change to https. An I would use cookie-persistence and n...
dani82_22742
Nimbostratus
Jan 16, 2008Hi tried the solution from deb. The only problem is, if a user connect the first time direct with https, then the lb can't find any cookie and he never add one.
when RULE_INIT {
see SOL6917 for cookie encoding details: https://tech.f5.com/home/solutions/sol6917.html
set ::myCookieName BigIP_cash_cms
set ::debug 1
}
when HTTP_REQUEST {
grab encoded cookie value & parse into relevant pieces
if {[HTTP::cookie exists $::myCookieName]}{
scan [HTTP::cookie $::myCookieName] "%d.%d.%d" myIpE myPortE unused
if {$::debug != 0}{log local0. "myIpD=$myIpE myPortE=$myPortE unused=$unused"}
calculate IP
set myIpH [format %x $myIpE]
if {$::debug != 0}{log local0. "myIpH=$myIpH"}
set myIpD1 [expr 0x[substr $myIpH 6 2]]
set myIpD2 [expr 0x[substr $myIpH 4 2]]
set myIpD3 [expr 0x[substr $myIpH 2 2]]
set myIpD4 [expr 0x[substr $myIpH 0 2]]
set myIpD "$myIpD1.$myIpD2.$myIpD3.$myIpD4"
if {$::debug != 0}{log local0. "myIpD=$myIpD"}
set node
node $myIpD 81
} else {
if {$::debug != 0}{log local0. "cookie $::myCookieName not found"}
}
}
so i thought that i can add a cookie on the response. That's working not bad, but if I change after in the same session to http, it doesn't work. I can't find the failure.
when HTTP_RESPONSE {
add session cookie to response
if {[HTTP::cookie exists $::myCookieName]}{
} else {
if {$::debug != 0}{log local0. "add cookie $::myCookieName to response"}
if {$::debug != 0}{log local0. "cookie $::myCookieName for server [LB::server addr]"}
scan [LB::server addr] "%d.%d.%d.%d" myIP1 myIP2 myIP3 myIP4
set myCookieValue "[format %x $myIP4][format %x $myIP3][format %x $myIP2][format %x $myIP1]"
HTTP::cookie insert name $::myCookieName value "[expr 0x$myCookieValue].0.0000"
}
}
when LB_SELECTED {
for the case, that no cookie was available in "HTTP:REQUEST" change here to port 81
set myLBPort [LB::server port]
if {$::debug != 0}{log local0. "myLBAddr=[LB::server addr] mylBPort=$myLBPort"}
if {$myLBPort == 0}{
if {$::debug != 0}{log local0. "myLBPort is 0"}
set myLBAddr [LB::server addr]
node $myLBAddr 81
LB::reselect
}
}
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