For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

CBerg64_161993's avatar
CBerg64_161993
Icon for Nimbostratus rankNimbostratus
May 19, 2015

iRule to select Pool

I have 2 pools that need to be access by the same url but with different jsp files. Ie. test.com/test1.jsp goes to pool 1 and test.com/test2.jsp goes to pool 2. But no other content for the site has test1.jsp or test2.jsp in the URL. Is it possible to create a iRule with or without a data group that will select a pool with on the first URL of a new session? ie if a user goes to test.com/test1.jsp and that session is directed to pool1, i need the remainder of the traffic on that session to be directed to the same pool. I've attempted different flavors of persistence and they seem to inspect every URL requested. A example of a iRule i attempted is below. Thanks in advance for the help.

when HTTP_REQUEST {
if { [HTTP::uri] contains "test1.jsp" } {
pool Test1-pool
persist cookie insert Campus-Cookie "0d 10:00:00"
} elseif { [HTTP::uri] contains "test2.jsp"} {
pool Test2-pool
persist cookie insert Campus-Cookie "0d 10:00:00"
}
}

5 Replies

  • What happened after test1.jsp? After user access test1.jsp or test2.jsp, would user direct to different web page? the Irule only works if user stays on test1.jsp or test2.jsp

     

  • In the initial URL that a user uses will have the test1.jsp or test2.jsp. I'm looking for a way to persist to the server their initial connection is on for the remainder of the session.

     

  • you need to add another condition in your Irule based on cookie persistency

     

    since your test condition in your current Irule only validate test1.jsp and test2.jsp, If there is any other user session after that, it does not go through the Irule

     

  • Right, that i know. What i don't know is the proper way to add the additional condition to make that happen. Thanks for the help.

     

  • Hi,

    i've just written the following. You can try this, but without any guaranty 😉

    when HTTP_REQUEST {
        if { [HTTP::cookie exists Pool]} {
            switch [HTTP::cookie Pool] {
                "pool1" {
                    pool Test1-pool
                }
                "pool2" {
                    pool Test2-pool
                }
            }
    
        } else { 
            if { [HTTP::uri] contains "test1.jsp" } {
                pool Test1-pool
            } elseif { [HTTP::uri] contains "test2.jsp"} {
                pool Test2-pool
            }
        }   
    }
    
    
    when HTTP_RESPONSE {
        if { [HTTP::uri] contains "test1.jsp" } {
            HTTP::cookie insert name Pool value "pool1"
        } elseif { [HTTP::uri] contains "test2.jsp"} {
            HTTP::cookie insert name Pool value "pool2"
        }   
    }
    

    Regards Alex