I have no knowledge of F5 and trying to read these rules. If some one can help me understand them.
Following rules is reading HTTP request and (defining variable INTRSSN?) getting a node and saving it in a persistence table.
when HTTP_REQUEST {
if { ( [HTTP::method] eq "POST") and
( [HTTP::path] equals "/webserv/Interaction") and
( [HTTP::header value "Content-Length"] < 1024 ) }{
#Debugging Purpose
#log local0. "First Request: [HTTP::uri]"
HTTP::collect [HTTP::header Content-Length]
if { [info exists "INTRSSN"] }{
set IntrExist [persist lookup uie $INTRSSN node]
#log local0. "Response check if exist $IntrExist"
if {($IntrExist != "")}{
node $IntrExist
}
}
}
}
This rule will read the HTTP request and extract a specific tag value is put it in INTRSSN variable. This variable will be saved in persistence table.
when HTTP_REQUEST_DATA {
if { ( [HTTP::path] equals "/webserv/Interaction") and
( [HTTP::header value "Content-Length"] < 1024 ) }{
set INTRSSN [findstr [HTTP::payload] "<soap1:sessionID>" 17 "<"]}
if { $INTRSSN != "" } {
#Debugging Purpose
#log local0. "SOAP Session ID: $INTRSSN"
catch { persist uie "$INTRSSN"}
#log local0. "Request_Data $INTRSSN"
}
}
I did not understand this event.
when HTTP_RESPONSE {
if { [HTTP::header "Content-Type" ] equals "text/xml" }{
set resdata [HTTP::payload]
set INTRSSN [findstr $resdata "<sessionID>" 11 "<"]
if { $INTRSSN != "" } {
#Debugging Purpose
#log local0. "Found sessionID on Response: $INTRSSN in SOAP response from: [LB::server addr]"
#log local0. "Interaction $INTRSSN"
catch {persist add uie $INTRSSN 600}
}
}
}
The HTTP_RESPONSE
portion attempts to read the XML response and also extract a specific tag value, put it in the $INTRSSN value and save/update a persistence record.
Basically, the whole iRule put together is a way of mapping a specific field within the HTTP body to use for persistence (ensuring the connection goes to the same backend server for the life of the connection).