Forum Discussion

Peter__Chan_109's avatar
Peter__Chan_109
Icon for Nimbostratus rankNimbostratus
Sep 30, 2005

Rules convert problem from 4.5.12 to v9

Hi folks,

 

Could anyone please help figure out my problem to convert a rule from v4.5.12 to v9? I'm using the OTCU conversion during an upgrade from v4.5.12 to v9.1 but it always show syntax error in the rules portion. The rule syntax is as follows:

 

 

load balancing rules

 

rule webservice {

 

if (http_host matches_regex "www.test.com.hk") {

 

use pool http4_pool

 

}

 

else {

 

use pool http_pool

 

}

 

}

 

rule redirect_rule {

 

redirect to "http://example.test.com/%u"

 

}

 

rule http_redirect {

 

if (substr(tcp_content(2), 0, 2) == "X") {

 

use pool test80

 

}

 

else {

 

use pool test84

 

}

 

}

 

rule http_redirect_80 {

 

if (substr(tcp_content(1), 0, 1) == "X") {

 

use pool testing_pool

 

}

 

else {

 

use pool testing_pool84

 

}

 

}

 

rule http_redirect_84 {

 

if (substr(tcp_content(2), 0, 2) == "X") {

 

use pool testing_pool

 

}

 

else {

 

use pool testing_pool84

 

}

 

}

 

rule https_redirect_443 {

 

if (substr(tcp_content(2), 0, 2) == "X") {

 

use pool https_pool

 

}

 

else {

 

use pool https_443_pool

 

}

 

}

 

rule webservice {

 

if (http_host matches_regex "test.domain.com" or http_host matches_regex "www.domain.com") {

 

use pool http2_pool

 

}

 

else {

 

use pool http_pool

 

}

 

}

 

 

:D

 

Please help.

 

 

Many thx

3 Replies

  • Your first rule might look like this in v9

    
    rule webservice {
    when HTTP_REQUEST {
        if {[HTTP::host] eq "www.test.com.hk"} {
           use pool http4_pool
        } else {
           use pool http_pool
        }
     }
    }
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    You should contact support to open a case for the otcu problem so they can collect the necessary information and determine why it is not working.

     

     

    I'm sure someone on the forum can help finish converting your rule to v9. Then you can delete it from your 4.x config and rerun the otcu.

     

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Here's an example of how to convert one of your other rules:

    rule http_redirect {
       if (substr(tcp_content(2), 0, 2) == "X") {
          use pool test80
       }
       else {
          use pool test84
       }
    }

    becomes:
    
    rule http_redirect [
       when CLIENT_ACCEPTED {
          TCP::collect
       }
       when CLIENT_DATA {
          if { [TCP::payload] starts_with "X" } {
             use pool test80
          } else {
             use pool test84
          }
          TCP::release
       }
    }

    I'm not sure you need to use substr since you are only extracting the first 2 bytes and the starts_with operator will only compare the first bytes with the provided string. So, this is sort of an optimization, not just a conversion.

    Also, your last rule, you shouldn't use matches_regex since in regular expressions, the dot . actually means match anything. I don't actually see any regular expression, so you should simply check for equality using the "eq" operator:

    rule webservice {
       if { ([HTTP::host] eq "test.domain.com") or ([HTTP::host] eq "www.domain.com")} {
          use pool http2_pool
       } else {
          use pool http_pool
       }
    }