Forum Discussion

jwhitepnv_12764's avatar
jwhitepnv_12764
Icon for Nimbostratus rankNimbostratus
Apr 12, 2005

Persist based on a portion of SID

I have an application that returns URLs that look like this:

 

https://www.xyz.com/ires/en-us/html/SignIn?sid=JSNd.fstR2gz5Y.6&return-to=HomePage

 

The ".6" at the end of the "sid=" string uniquely identifies the server. How do I create a rule to persist users with a .6 extention to a server with a specific ip address. For example all .6 URLs go to 10.10.10.6:80?

 

 

Thanks for your help.
  • Assuming the sid=JSNd.fstR2gz5Y. is a static length before your Identifier of 6, and that the & is always the terminator, you can pull out the identifier and set it to a variable. Here's a start:

    when HTTP_REQUEST { 
       if { [HTTP::cookie exists "persist_me"] } { 
         persist uie [HTTP::cookie "persist_me"] 
         } 
     } 
            
     when HTTP_RESPONSE { 
       set server_id [ findstr [HTTP::uri] "sid" 19 "&"] 
       You'll need logic here to compare the value of server_id 
       to the real server, and create new variable to insert into 
       cookie so when the HTTP_REQUEST is performed, no additional 
       processing will be required. 
       HTTP::cookie insert name persist_me value $server_id 
     }

    If you just want to make sure you are persisting to the server responding, it might be easier to persist by extracting the responding server's information:

    when HTTP_REQUEST {  
       if { [HTTP::cookie exists "persist_me"] {  
         set cookie_contents [HTTP::cookie persist_me] 
         set poolid [lindex cookie_contents 0] 
         set serverid [lindex cookie_contents 1] 
         set portid [lindex cookie_contents 2] 
         use pool $poolid member $serverid $portid 
         } else { 
           use pool $poolid 
           }     
       }  
      
     when HTTP_RESPONSE {  
       HTTP::cookie insert name persist_me value [LB::server] 
       }

  • The cookie in the HTTP_RESPONSE should be persist_me, not g2_cooks. Sorry.