Forum Discussion

Chris_G_01_1415's avatar
Chris_G_01_1415
Icon for Nimbostratus rankNimbostratus
Jul 03, 2014

iRule to use specific HTTP profile

Hello, I am trying to simplify some of our current configurations. Right now we are manually configuring each URL, like "xyzdev.com", to use a specific HTTP profile. We have multiple environments which use different HTTP profiles we have configured. I was thinking of creating an iRule that can match "xyzdev.com" in the URL then use this specific HTTPdev profile or "xyztest.com" to use the HTTP test profile. Anyone know if that is possible using iRules or can anyone suggest a better way?

 

4 Replies

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    What type of customizations/differences do you have among the custom http profiles?

     

  • The only thing that I can tell is different is the urls that get encrypted cookies. Under our dev http profile, encrypt cookies field, we have 10 urs, like dev1, dev2, dev3, etc. We have the same for test and stage. I guess I am just trying to figure out is if there is a much simpler way to configure this rather than manually add a URL to the encrypt cookies field each time a new one is created.

     

  • You don't need to switch between HTTP profiles if you're just encrypting cookies. An iRule will do the job. Here's a variation of the HTTP cookie encryption article:

    https://devcentral.f5.com/wiki/iRules.EncryptingCookies.ashx

    when CLIENT_ACCEPTED {
        set cookielist [list "USERID" "METRICS"]
        set encryption_passphrase "abcd1234"
    }
    when HTTP_REQUEST {
        foreach x [HTTP::cookie names] {
            if { [lsearch $cookielist $x] ne "-1" } {
                set decrypted [HTTP::cookie decrypt $x $encryption_passphrase]
                if { $decrypted eq "" } {
                    HTTP::cookie remove $x
                }
            }
        }
    }
    when HTTP_RESPONSE {    
        foreach x [HTTP::cookie names] {
            if { [lsearch $cookielist $x] ne "-1" } {
                HTTP::cookie encrypt $x $encryption_passphrase
            }
        }
    }