Forum Discussion

Mayank_Shukla's avatar
Mayank_Shukla
Icon for Altostratus rankAltostratus
Mar 10, 2015

Please help in creating a content switching irule

Below is the requirement:- If url https://xyz.abc.com contains below switches ; it should point to pool1:-

 

/providerportal1/* - proxy to pool1 /Resources/* - proxy to pool1 /provider_get/* - proxy to pool1 /exadmin/* - proxy to pool1

 

else if url contains below switch;it should point to pool2

 

/portal/* - proxy to pool2

 

example :

 

1.https://xyz.abc.com/Resources/ >>>pool1 2.https://xyz.abc.com/exadmin/ >>>pool1 3.https://xyz.abc.com/portal/ >>>pool2

 

2 Replies

  • Give it a shot.

    when HTTP_REQUEST {
    
      if {[HTTP::host] == "xyz.abc.com"} {
        switch -glob [HTTP::uri] {
          "/providerportal1/*" -
          "/Resources/*" -
          "/provider_get/*" -
          "/exadmin/*" {
            pool pool1
          }
          "/portal/*" {
            pool pool2
          }
        }
      }
    
    }
    
  • I would make a couple of minor changes for efficiency(HTTP::path rather than HTTP::uri), and to deal with the possibility of upper/lower case requests(string tolower):

    when HTTP_REQUEST {
    
      if {[string tolower[HTTP::host]]  == "xyz.abc.com"} {
        switch -glob [string tolower[HTTP::path]]  {
          "/providerportal1/*" -
          "/resources/*" -
          "/provider_get/*" -
          "/exadmin/*" {
            pool pool1
            }
          "/portal/*" {
            pool pool2
            }
          }
        }
    
      }