Forum Discussion

Meena_60179's avatar
Meena_60179
Icon for Nimbostratus rankNimbostratus
May 04, 2010

Pool Settings on Http redirect

I have two pools in one virtual server both pool serves different applications (like gmail & docs) and there is one pool for authenticating user request which is default pool for this virtual server, user can access any pool after logging in depending on which application he wants to go to. That setting is stored in a cookie. After user logs into desired application his session needs to be persisted across session. But for some reason even after setting Http pool to appserver_pool_1 or appserver_pool_2 subsequent requests point to auth pool instead of desired pool and I get an error. The only reason I could think of here is when user goes to any server inside i.e. appserver_pool_1, that server redirects him to a page and all subsequent requests who has session comes after redirection, could that cause an issue here? How can I resolve that issue. I appreciate your help very much, thanks.

4 Replies

  • Here is the iRule I am using

     
    when HTTP_REQUEST {
    set uri [ HTTP::uri ]
    if { $uri contains "myapp" } {
     find out if session id is defined
    set sessionId [ HTTP::cookie "JSESSIONID" ] 
    if { $sessionId == "" } {
     look for auth cookie
    set authCookie [ HTTP::cookie "auth.mail.com" ]
    set location [HTTP::cookie "mail_location" ]
    if {  $authCookie != "" and $location != "" } {
    if { $location equals "mailloc" } {
        pool appserver_pool_1
        } elseif {$location equals "docloc" } {
                                        pool appserver_pool_2
                               }
        }
    else {
                                Redirect to authentication page
        HTTP::redirect "http://10.10.0.1/auth/"
        }
        } else {
    persist session
                           persist uie $sessionId 3600
        }
        }
    }
    when HTTP_RESPONSE {
      set SessionId [HTTP::cookie "JSESSIONID"]
      if { $SessionId != "" }{ 
       log "app server has set JSESSIONID $SessionId add persistence"
       
        persist off session id for an hour (3600 seconds)
       persist add uie $SessionId 3600 
      }
    }
    
  • Can some one please help me here, since I am new to iRule I got no clue on how can I set up this persistence for two pools and to the servers inside any pool.

     

     

    Thanks for the help.
  • Hi Meena,

     

     

    How are you selecting the different pools? Is there another iRule or a different version of the iRule you posted above?

     

     

    Thanks,

     

    Aaron
  • I want to select the pool only when user logs in for the first time i.e. when $location != "" and $authCookie != "" , I am assuming that for next subsequent requests this pool settings will be persisted and app_server_pool_1 will serve all the request for this session (since I have persistence based on JSESSIONID). Is there anything wrong with this approach or am I missing something here. I do have couple of HTTP redirects , are those breaking pool settings? I tried adding this code into above mentioned iRule

     

     

     
     session exist 
    else {
      persist uie $sessionId 3600
      set location [HTTP::cookie "my_location"]
      if {$location equals "mail_loc"} {
          pool app_server_pool_1
      }else {
         pool app_server_pool_2
    }
    }
    

     

    everything works fine but that means I am checking location every time a request comes in and assigning pool for that request, even though location does not change with in a session. I appreciate your help. Thanks.