Forum Discussion

Net_Admin_86160's avatar
Net_Admin_86160
Icon for Nimbostratus rankNimbostratus
Oct 24, 2012

Case Issue

Hello,

 

In just this section(first elseif below) of the irule I have the "and" condition. But somehow in this section ignore case is not working.

 

 

elseif {([HTTP::host] contains "domain1.mydomain.com" or [HTTP::host] contains "domain2.mydomain.com" or [HTTP::host] contains "domain3.mydomain.com" or [HTTP::host] contains "domain4.mydomain.com" or [HTTP::host] contains "domain5.mydomain.com" or [HTTP::host] contains "domain6.mydomain.com") and ([string tolower [HTTP::uri]] contains "/preference/" or [string tolower [HTTP::uri]] contains "/mass/" or [string tolower [HTTP::uri]] contains "/ge/" or [string tolower [HTTP::uri]] contains "/et/" or [string tolower [HTTP::uri]] contains "/cpro/" or [string tolower [HTTP::uri]] contains "/clb/" or [string tolower [HTTP::uri]] contains "/autm/" or [string tolower [HTTP::uri]] contains "/airb/" or [string tolower [HTTP::uri]] contains "/amt/" or [string tolower [HTTP::uri]] contains "/gsm/" or [string tolower [HTTP::uri]] contains "/avio/" or [string tolower [HTTP::uri]] contains "/iif/" or [string tolower [HTTP::uri]] contains "/fg/" or [string tolower [HTTP::uri]] contains "/cpd/" or [string tolower [HTTP::uri]] contains "/pten/" or [string tolower [HTTP::uri]] contains "/ooh/" or [string tolower [HTTP::uri]] contains "/yg/" or [string tolower [HTTP::uri]] contains "/rpn/" or [string tolower [HTTP::uri]] contains "/fms/" or [string tolower [HTTP::uri]] contains "/ems/" or [string tolower [HTTP::uri]] contains "/kbdn/" or [string tolower [HTTP::uri]] contains "/qur/" or [string tolower [HTTP::uri]] contains "/fl/" or [string tolower [HTTP::uri]] contains "/sdce/" or [string tolower [HTTP::uri]] contains "/acme/" or [string tolower [HTTP::uri]] contains "/hwlm/" or [string tolower [HTTP::uri]] contains "/acon/" or [string tolower [HTTP::uri]] contains "/stec/" or [string tolower [HTTP::uri]] contains "/sst/" or [string tolower [HTTP::uri]] contains "/secu/" or [string tolower [HTTP::uri]] contains "/conc/" or [string tolower [HTTP::uri]] contains "/evt/" or [string tolower [HTTP::uri]] contains "/utp/" or [string tolower [HTTP::uri]] contains "/pvm/" or [string tolower [HTTP::uri]] contains "/lepn/" or [string tolower [HTTP::uri]] contains "/rdb/" or [string tolower [HTTP::uri]] contains "/let/" or [string tolower [HTTP::uri]] contains "/edc/" or [string tolower [HTTP::uri]] contains "/mae/" or [string tolower [HTTP::uri]] contains "/wmw/" or [string tolower [HTTP::uri]] contains "/qp/" )} {

 

use pool WEBFORMS

 

} elseif {[string tolower [HTTP::uri]] starts_with "/webservices/rest/brand/"} {

 

if {[string tolower [HTTP::uri]] contains "/dataqueue"} {

 

HTTP::redirect "]"

 

}

 

elseif {[string tolower [HTTP::uri]] contains "/comp"} {

 

HTTP::redirect "]"

 

} else {

 

HTTP::redirect "]"

 

}

 

}

 

 

 

Any help with this is appreciated. If there is a better way to write this ..please let me know .. will welcome any suggestions to improve.

 

Thanks

 

10 Replies

  • Wow, that's one long rule! I'd suggest using a Data Group for the host names and another for the URIs. If nothing else you're rule will be faster and easier to read and easier to modify in future (you just add new hosts or URI's to the DGs). Hopefully and possible mistake in your current code will be cleared up with this too.

     

     

    
    ...
    elseif { [class match [string tolower [HTTP::host]] contains host_dg ] } { 
                use pool XXX
    }
    elseif { [class match [string tolower [HTTP::uri]] contains uri_dg ] } { 
                use pool XXX
    }
    ...
    

     

  • But somehow in this section ignore case is not working.does it relate to if-else order?

    Any help with this is appreciated. If there is a better way to write this e.g.

    [root@ve10:Active] config  b class host_class list
    class host_class {
       {
          "domain1.mydomain.com"
          "domain2.mydomain.com"
          "domain3.mydomain.com"
          "domain4.mydomain.com"
          "domain5.mydomain.com"
          "domain6.mydomain.com"
       }
    }
    [root@ve10:Active] config  b class uri_class list
    class uri_class {
       {
          "/acme/"
          "/acon/"
          "/airb/"
          "/amt/"
          "/autm/"
          "/avio/"
          "/clb/"
          "/conc/"
          "/cpd/"
          "/cpro/"
          "/edc/"
          "/ems/"
          "/et/"
          "/evt/"
          "/fg/"
          "/fl/"
          "/fms/"
          "/ge/"
          "/gsm/"
          "/hwlm/"
          "/iif/"
          "/kbdn/"
          "/lepn/"
          "/let/"
          "/mae/"
          "/mass/"
          "/ooh/"
          "/preference/"
          "/pten/"
          "/pvm/"
          "/qp/"
          "/qur/"
          "/rdb/"
          "/rpn/"
          "/sdce/"
          "/secu/"
          "/sst/"
          "/stec/"
          "/utp/"
          "/wmw/"
          "/yg/"
       }
    }
    
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       set uri [string tolower [HTTP::uri]]
    
       if { [class match -- [HTTP::host] equals host_class] or
            [class match -- $uri contains uri_class] } {
          pool WEBFORMS
       } elseif { $uri starts_with "/webservices/rest/brand/" } {
          if { $uri contains "/dataqueue"} {
             HTTP::redirect "http://[HTTP::host]/cgi-win/rqueue.cgi?param=[HTTP::uri]"
          } elseif { $uri contains "/comp" } {
             HTTP::redirect "http://[HTTP::host]/cgi-win/rcref.cgi?param=[HTTP::uri]"
          } else {
             HTTP::redirect "http://[HTTP::host]/cgi-win/rlookup...[HTTP::uri]"
          }
       } else {
           do something
       }
    }
    }
    
  • Sorry about this but i am new to data groups

     

     

    Internal Class Format (v11.0):

     

     

    01 ltm data-group internal name_value_dg {

     

     

    02 records {

     

     

    03 name1 {

     

     

    04 data value1

     

     

    05 }

     

     

    06 name2 {

     

     

    07 data "value2 with spaces"

     

     

    08 }

     

     

    09 }

     

     

    10 type string

     

     

    11 }

     

     

     

     

     

    This needs a key-value pair .. i am not sure How to build the datagroups.....

     

     

    ltm data-group internal /Common/WebformsDomains_dg {

     

    records {

     

    domain1.mydomain.com {

     

    data domain1.mydomain.com

     

    }

     

    domain2.mydomain.com {

     

    data domain2.mydomain.com

     

    }

     

    }

     

    type string

     

     

     

    Is this correct?

     

  • e.g.

    [root@ve11a:Active:Changes Pending] config  tmsh list ltm data-group internal host_class
    ltm data-group internal host_class {
        records {
            domain1.mydomain.com { }
            domain2.mydomain.com { }
            domain3.mydomain.com { }
            domain4.mydomain.com { }
            domain5.mydomain.com { }
            domain6.mydomain.com { }
        }
        type string
    }
    [root@ve11a:Active:Changes Pending] config  tmsh list ltm data-group internal uri_class
    ltm data-group internal uri_class {
        records {
            /acme/ { }
            /acon/ { }
            /airb/ { }
            /amt/ { }
            /autm/ { }
            /avio/ { }
            /clb/ { }
            /conc/ { }
            /cpd/ { }
            /cpro/ { }
            /edc/ { }
            /ems/ { }
            /et/ { }
            /evt/ { }
            /fg/ { }
            /fl/ { }
            /fms/ { }
            /ge/ { }
            /gsm/ { }
            /hwlm/ { }
            /iif/ { }
            /kbdn/ { }
            /lepn/ { }
            /let/ { }
            /mae/ { }
            /mass/ { }
            /ooh/ { }
            /preference/ { }
            /pten/ { }
            /pvm/ { }
            /qp/ { }
            /qur/ { }
            /rdb/ { }
            /rpn/ { }
            /sdce/ { }
            /secu/ { }
            /sst/ { }
            /stec/ { }
            /utp/ { }
            /wmw/ { }
            /yg/ { }
        }
        type string
    }
    
  • Thanks much

     

     

    I was able to create the datagroups and add it to the irule...but the case issue still persists

     

     

    elseif {[class match [string tolower [HTTP::host]] contains WebformsDomains_dg] and [class match [string tolower [HTTP::uri]] contains WebformsUri_dg] } {

     

    use pool WEBFORMS

     

    } elseif {[string tolower [HTTP::uri]] starts_with "/webservices/rest/brand/"} {

     

    if {[string tolower [HTTP::uri]] contains "/dataqueue"} {

     

    HTTP::redirect "http://[HTTP::host]/cgi-win/rqueue.cgi?param=[HTTP::uri]"

     

    }

     

    elseif {[string tolower [HTTP::uri]] contains "/comp"} {

     

    HTTP::redirect "http://[HTTP::host]/cgi-win/rcref.cgi?param=[HTTP::uri]"

     

    }

     

    else {

     

    HTTP::redirect "http://[HTTP::host]/cgi-win/rlookup.cgi?param=[HTTP::uri]"

     

    }

     

    }

     

     

     

     

    eg: /secu will take to the correct pool , yet /SECU will not
  • https://domain1.mydomain.com/secu/form.do?p=pppp&r=@%7bencrypted_customer_id%7d@ -- works

     

    https://domain1.mydomain.com/SECU/form.do?p=pppp&r=@%7bencrypted_customer_id%7d@ --- does not
  • https://domain1.mydomain.com/secu/form.do?p=pppp&r=@%7bencrypted_customer_id%7d@ -- works

     

    https://domain1.mydomain.com/SECU/form.do?p=pppp&r=@%7bencrypted_customer_id%7d@ --- does not
  • This has been resolved...

     

    thanks much for all your help .. it helped narrow down the issue.