Forum Discussion

Nick_T_68319's avatar
Nick_T_68319
Icon for Nimbostratus rankNimbostratus
Apr 01, 2014

Select pool based on URI and maintain with cookie

I don't know if this is possible, but I want to select a different pool based off something in the URI. like ?site=testsite perhaps. But the problem is, I want to persist it to that pool even if that string is no longer in the URI. So the first page land will have it in the URI, but the rest of the journey wont.

 

when HTTP_REQUEST { if { [HTTP::uri] contains "testsite" } { { pool testsite-pool } }

 

2 Replies

  • Hi mate!

    Check out this article?

    Maybe something like this?

    when HTTP_REQUEST { 
        if { [string tolower [HTTP::uri]] contains "testsite" } {
            persist cookie insert testsite_persist 0
            pool testsite-pool
        }
    }
    

    /Patrik

  • I think you can just use normal cookie persistence profile on the virtual without using an iRule for it, however you will need to use another cookie to say "use test pool". Try this;-

    when HTTP_REQUEST { 
        set fAddCk 0
        if {[HTTP::cookie exists "X-testpool"]} {
            pool pl_test_http
        } elseif { [string tolower [HTTP::uri]] contains "testsite" } {
            pool pl_test_http
             Set flag to insert cookie if it doesn't already exist
            set fAddCk 1
        }
    }
    when HTTP_RESPONSE {
        if {$fAddCk} {
            HTTP::cookie insert name "X-testpool" value "blah"
        }
    }