Forum Discussion

Cta_dev_116550's avatar
Cta_dev_116550
Icon for Nimbostratus rankNimbostratus
Mar 11, 2015

Host with Multiple URI

Hello, I have one listening IP for many application's, within the application some have requirement for datagroup to allow specific source IP's, but withing one application I have multiple uri's, therefor i was gone use switch say for "www.test.com" with the following uri's, allowed source ip go to this pool, for "www.test2.com with the following uri's with allowed source ip go to this pool and so forth, i was planing using two swicth statements

 

one for host and the second within the host for uri's i'm getting so much error is this supported

 

when HTTP_REQUEST { swicth [for host] "www.test.com" swicth for uri this will be inside the first swicth "/uri1" - "/uri2" - if the match class is datagroup source IP forward to this pool otherwise reject close the uri switch and use the second host

 

"www.test2.com swicth [for uri] list of uri's "/uri3" - "/uri4" - if the match class is datagroup named source IP2 forward to this pool/pools otherwise reject

 

5 Replies

  • I got this resolved using the following,

    when HTTP_REQUEST {

    switch -glob [string tolower [HTTP::host]] {

    "www.test1.com” {

    switch -glob [string tolower [HTTP::uri]] {

     “/uri1" -
     “/uri2" -
            {
    

    if { ([class match [IP::remote_addr] equals $::Customer_Allowesd_IP]) } { return } }

    }
    

    "www.test2.com” {

    switch -glob [string tolower [HTTP::uri]] {

     “/uri3" -
     “/uri4" -
            {
    

    if { ([class match [IP::remote_addr] equals $::Customer_Allowesd_IP]) } { return } }

    }
    

    }

  • $::Customer_Allowesd_IP

    what version are you using? starting from 9.4.4, $:: is no longer needed to reference data group and it is cmp friendly now.

    Class / Data Group List References
    
    9.4.0 - 9.4.3, class reference not compatible as of 9.4.4, "::" and "$::" prefixes are no longer required to reference classes using findclass or matchclass. Classes are static and are therefore CMP compatible. There is no need to treat them as global objects.
    
    10.0, matchclass / findclass deprecated in favor of new class command
    

    CMP Compatibility

    https://devcentral.f5.com/wiki/iRules.cmpcompatibility.ashx
  • thanks updated without the prefix

    when HTTP_REQUEST {

    switch -glob [string tolower [HTTP::host]] {

    "www.test1.com { switch -glob [string tolower [HTTP::uri]] {

     “/uri1" -
     “/uri2" -
            {
    

    if { ([class match [IP::remote_addr] equals "Customer_Allowesd_IP"]) } { return } }

      }
    

    "www.test2.com {

    switch -glob [string tolower [HTTP::uri]] {

     “/uri1" -
     “/uri2" -
            {
    

    if { ([class match [IP::remote_addr] equals "Customer_Allowesd_IP"]) } { return } }

      }
    
      }
    
    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      if you do not use glob-style matching, you know, you can remove -glob option.
  • Thank you, I'll do that I just wanted to make it work first as I was not sure if the entry with regards to DataGroups in multiple switch statement would be accepted.