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

abhy201's avatar
abhy201
Icon for Nimbostratus rankNimbostratus
Mar 19, 2018

Content Switching for URL using iRule and different Pools

I am trying to create a basic iRule to switch content. I am using single Vserver and need to switch content for 2 different Http URL's using 2 different pools with associated backends servers.

 

URL1. "abc.com" URL2. "xyz.com"

 

URL1 needs to use Pool1 and url2 needs to use Pool2.

 

Looking at some of your previous questions, I created the below iRule. Can anyone please confirm if this is accurate or something needs to be changed.

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "abc.com" { pool pool_1} "xyz.xom" { pool pool_2} } }

 

1 Reply

  • How about something like this,

    Create a DataGroup to map "host header names" to Pool mappings. example HOST2POOL_DG

    "abc.com" := "POOL01",

    "xyz.com" := "POOL02",

    when HTTP_REQUEST {
        set pool_select_value [class lookup [string tolower [HTTP::host]] HOST2POOL_DG]
        pool $pool_select_value
    }
    

    or

    simple irule:
    when HTTP_REQUEST {
            switch [string tolower [HTTP::host]] {        
            "abc.com" { pool POOL01}        
            "xyz.com" { pool POOL02}        
            }
     }