Forum Discussion

MattC_58842's avatar
MattC_58842
Icon for Nimbostratus rankNimbostratus
Dec 08, 2011

Persistance in a I-rule

So I have this I-rule

 

 

when HTTP_REQUEST {

 

set uri [HTTP::uri]

 

switch $uri {

 

"/" { HTTP::redirect "https://[HTTP::host]/tf/WalletShare" }

 

"/tf/WalletShareREIT" { pool wdc-wshwstst-5002 }

 

"/tf/WalletShare" { pool wdc-wshwstst-5001 }

 

}

 

}

 

 

 

 

 

Once a connection comes in and hits the pool based off its uri , I want that connection to stick with that same pool no matter what is in the uri after the initial connection. I think my problem is as it builds the page different uri are created and its not being sent to the same pool

6 Replies

  • Hi Matt,

     

     

    You could check for a cookie in HTTP_REQUEST indicating a pool selection had already been made. If no cookie was found in the request, you could set a cookie using HTTP::cookie insert with the name of the pool to use in HTTP_RESPONSE. You'd want to validate that the cookie name was either 5001 or 5002 to prevent someone from accessing an arbitrary pool.

     

     

    I can whip up an example in a bit.

     

     

    Aaron
  • Here's an example of what I was thinking. It uses a session cookie to track whether an initial pool selection has been made. Once a pool has been selected, a separate session cookie is used for persistence within the pool.

    Make sure to test with a OneConnect profile enabled on the virtual server. If you're using serverside source address translation, you can use the default OneConnect profile with a /0 source mask. Else, use a custom OneConnect profile with a /32 source mask.

    
    when HTTP_REQUEST {
    
     Track whether to insert the pool selector cookie
    set insert_cookie 0
    
     Check if there is a pool selector cookie
    switch [HTTP::cookie value pool_selector] {
    1 {
     client already made a request so select the first pool
    pool wdc-wshwstst-5001
    
     Use cookie insert persistence to ensure client is persisted to same member within this pool
    persist cookie insert pool5001 0
    }
    2 {
     client already made a request so select the second pool
    pool wdc-wshwstst-5002
    
     Use cookie insert persistence to ensure client is persisted to same member within this pool
    persist cookie insert pool5002 0
    }
    default {
    
     No cookie, so check the URI
    switch [HTTP::uri] {
    "/" { HTTP::redirect "https://[HTTP::host]/tf/WalletShare" }
    "/tf/WalletShareREIT" {
    pool wdc-wshwstst-5002
    set insert_cookie 2
    persist cookie insert pool5002 0
    }
    "/tf/WalletShare" {
    pool wdc-wshwstst-5001
    set insert_cookie 1
    persist cookie insert pool5002 0
    }
    }
    }
    }
    }
    when HTTP_RESPONSE {
    
     Check if we've made an initial pool selection for this request
    switch $insert_cookie {
    1 -
    2 {
     Insert the cookie in the response
    HTTP::cookie insert name pool_selector value $insert_cookie path /
    }
    }
    }
    

    Aaron
  • just curious whether it works if we do HTTP::disable after selecting a pool in HTTP_REQUEST.
  • I think calling HTTP::disable would only affect the current connection. So it wouldn't handle clients who make subsequent requests over a new TCP connection. And it would probably prevent a session cookie from being inserted into the response once a pool was selected for inter-pool persistence. Though I'm not sure Matt requires persistence within the pool.

     

     

    Aaron
  • thanks Aaron! i forgot about subsequential connections.
  • Thanks guys I will try out sorry for late response , was caught up on a few calls yesterday. As always very appreciative for your time.