Forum Discussion

Huber_Philipp_1's avatar
Huber_Philipp_1
Icon for Nimbostratus rankNimbostratus
Oct 20, 2014

iRule Syntax between v10.2.3 and 11.6.x

Hi all,

We plan to update v10.2.3 to 11.6.x. Are there any change´s to my used irule below ?

In 11.0.0 the deprecated commands are matchclass and findclass - should be no problem with my irules ?

In 11.4.0 the deprecated commands are HTTP:class, WAM:disable, WAM:enable and Events HTTP_CLASS_FAILED and HTTP_CLASS_SELECTED - should be no problem with my irules ?

In 11.5.0 the deprecated commands are ASM:violation_date and Events ASM_REQUEST_VIOLATION - i dont use..

....any other changes ?

These are a few parts of my irules:

when HTTP_REQUEST {
  set HTTPhost [HTTP::host]
  set HTTPpath [string tolower [HTTP::path]] 
  set HTTPuri [string tolower [HTTP::uri]] 

  switch -glob $HTTPpath {
    "/URLPATH*" {
      HTTP::header replace Host "xxxxx"
      HTTP::header replace "Accept-Encoding" "" 
      HTTP::header insert X-Forwarded-For [getfield [IP::client_addr] % 1]
      pool pl_xxxx
    }
    "/URLPATH/*" { 
      switch [active_members pl_Pool1] {
        "0" { pool pl_Pool2 }
        default { pool pl_Pool1 }
     }  
    default { 
      set response "([HTTP::uri])\r\n"
      HTTP::respond 200 content $response "Content-Type" "text/html"
    }

 }

when HTTP_RESPONSE
{
  switch -glob $HTTPpath {
    "/URLPATH/*" {
      STREAM::expression "@http://xxxxxxx@http://$HTTPhost/xxxxxxxxx@"
      STREAM::enable
    }
    default { 
      if {[HTTP::status] contains "404"} {
        set response "\r\n"
        HTTP::respond 200 content $response "Content-Type" "text/html"
      }
    }
  } 
}



Other Used Commands:

HTTP::redirect
[HTTP::uri] contains
SSL::disable serverside
snatpool
IP::addr [IP::remote_addr] equals (for remote IP matching)
HTTP::header insert "X-Forwarded-Proto" "https"
HTTP::respond 404 content $response "Content-Type" "text/html" "Cache-Control" "no-cache"
HTTP::cookie 
HTTP::query
substr
starts_with
ends_with


array set statuspools {
    "xx"   "yyy"
    "111"  "222"
  }

foreach {iname ipool} [array get statuspools] {
    switch [active_members $ipool] {
        "0" { set icolor "red" }
          default { set icolor "green" }
    }  
}



when HTTP_REQUEST {
  if { [HTTP::uri] eq "/" || 
       [HTTP::uri] eq "/proxy.pac" || 
       [HTTP::uri] eq "/wpad.dat" || } {
    set response "function FindProxyForURL(url, host)\r\n"
    append response "{\r\n"
    append response "  if ( shExpMatch(host, \"*.xxxxx.de\" )   ||\r\n"
    append response "       shExpMatch(host, \"*.xxxxx.de\") ||\r\n"
    append response "       shExpMatch(host, \"localhost\"))\r\n"
    append response "  {\r\n"
    append response "    return \"DIRECT\";\r\n"
    append response "  }\r\n"

    append response "  if ( shExpMatch(host, \"xxxxxxx.de\" )   ||\r\n"
    append response "       shExpMatch(host, \"*.yyyyyyy.de\"))\r\n"
    append response "  {\r\n"
    append response "    return \"PROXY 10.10.10.10:8080\";\r\n"
    append response "  }\r\n"
    append response "\r\n"
    append response "  return \"PROXY xxxxxxxxx:8080\";\r\n"
    append response "}\r\n"
  HTTP::respond 200 content $response "Content-Type" "application/x-ns-proxy-autoconfig"
  }
}


set HTTPcontentType [string tolower [HTTP::header "Content-Type"]] 

        switch -glob $HTTPcontentType {
          "text/xml*" {
            append response "........."

          }
          "application/soap+xml*" {
            append response "........."
          }
        }