Forum Discussion

ScottTS's avatar
ScottTS
Icon for Nimbostratus rankNimbostratus
Mar 20, 2014

class statement irule

Hi. i was able to get this irule working with older code, but am struggling with the new class command that replaces findclass with 10.2 code. This is with 10.2.4 code. The irule performs a redirect by performing a lookup in a data class file. It works with the first five or so rows, but then fails on every row after that. Any help would be appreciated. thanks Scott

 

class apache_da_mapping {            

type string
   filename "/config/apache_da_class.dat"
   separator "+="
}

rule wng_apache_instance-rule {
   when HTTP_REQUEST {
       set mapurl [class lookup [HTTP::host] apache_da_mapping]
          log local0. "[HTTP::host] Match? $mapurl"

       if {$mapurl ne ""}{
         log local0. "[HTTP::host] Redirecting client to http://$mapurl[HTTP::uri]"
          HTTP::redirect "http://$mapurl[HTTP::uri]"
       }
    }

}
`

/config/apache_da_class.dat  (sample)  works up to the alamo line.  fails when it tries to match the first ent line and everything after.  
`"alm-lab2-d910" += "alm-lab2-d91.corp.ec.com:8760",
"alm-lab2-d910.corp.ec.com" += "alm-lab2-d91.corp.ec.com:8760",
"ent-pt-lab2-a900" += "ent-pt-lab2-a90.corp.ec.com:8750",
"ent-pt-lab2-a900.corp.ec.com" += "ent-pt-lab2-a90.corp.ec.com:8750",
  • what is the error, and what do your log statements look like?
  • thanks for your response JR. It has been sporadic. Sometimes the class lookup function returns nothing and the match is null. Sometimes it returns the item [HTTP::host] where the match is the same as the item.. Sometimes it actually works on the first couple of rows. Right now i reapplied the data class file. It works on the first row, but every row after that it returns the same as the item.

     

    Mar 21 10:01:55 local/tmm info tmm[5295]: Rule wng_apache_instance-rule : alm-lab2-a900.corp.ec.com Match? alm-lab2-a900.corp.ec.com Mar 21 10:01:55 local/tmm info tmm[5295]: Rule wng_apache_instance-rule : alm-lab2-a900.corp.ec.com Redirecting client to http://alm-lab2-a900.corp.ec.com/ Mar 21 10:01:55 local/tmm1 info tmm1[5296]: Rule wng_apache_instance-rule : alm-lab2-a900 Match? alm-lab2-a90.corp.ec.com:8760 Mar 21 10:01:55 local/tmm1 info tmm1[5296]: Rule wng_apache_instance-rule : alm-lab2-a900 Redirecting client to http://alm-lab2-a90.corp.ec.com:8760/

     

  • Hitting the rows toward the bottom of the file i get NULL responses as i mentioned above.

     

    Mar 21 10:26:50 local/tmm info tmm[5295]: Rule wng_apache_instance-rule : ent-pt-lab2-a900 Match?