Hi
I am looking for guidance on setting up persistence based on phpsessid. We are load balancing across 2 Apache web servers and are using phpsessid for persistence between the servers. I would like to setup an iRule to track the phpsessid in HTTP request/responses and persist to the correct server.
I have used the wiki @ https://devcentral.f5.com/wiki/iRul...sistence.ashx to try and achieve this with the following iRule code:
when RULE_INIT {
set ::debug 0
}
when HTTP_REQUEST {
set sessionID ""
set sessionID [findstr [HTTP::path] "PHPSESSID=" 10 26]
set persistTo [session lookup uie $sessionID]
if { $persistTo equals "" } {
pool [LB::server pool]
if {$::debug}{log local0. "No phpsession ID, load balancing the connection."}
} else {
pool [LB::server pool] member $persistTo
if {$::debug}{log local0. "PHPSESSID $sessionID sent to $persistTo"}
}
}
when HTTP_RESPONSE {
set sessionID ""
set sessionID [findstr [HTTP::path] "PHPSESSID=" 10 26]
set persistTo [session lookup uie $sessionID]
if { $persistTo equals "" } {
session add uie $sessionID [IP::server_addr] 1800
if {$::debug}{log local0. "added server entry $persistTo for PHPSESSID $sessionID"}
} else {
if {$::debug}{log local0. "existing server entry $persistTo for PHPSESSID $sessionID"}
}
}
when LB_FAILED {
If no servers are active, redirect to sorry page elsewhere
if {[active_members [LB::server pool]] == 0}{
HTTP::redirect http:://sorry.domain.com/NoServersAvail.html
if {$::debug}{log local0. "No servers available. Redirecting to sorry server."}
} else {
LB::detach
LB::reselect [LB::server pool]
if {$::debug}{log local0. "LB failed, re-load balancing to pool."}
}
}
The PHPSESSID is 26 characters long.
I have assciated this iRule with a Universal persistence profile and applied to Virtual Server.
However when testing I receive the following error:
TCL error: irule-phpsessid - wrong args: should be "session lookup uie " while executing "session lookup uie $sessionID"
Whats confusing me is how to check the server response using HTTP:: ?
This topic was been touched on before:
https://devcentral.f5.com/Community...fault.aspx
Any guidance here greatly appreciated. I'm consuming a *lot* of iRule doco in the process of getting this working. Way cool stuff