Forum Discussion
Peter__Chan_109
Nimbostratus
Sep 30, 2005Rules 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
- JRahm
Admin
Your first rule might look like this in v9rule webservice { when HTTP_REQUEST { if {[HTTP::host] eq "www.test.com.hk"} { use pool http4_pool } else { use pool http_pool } } } - unRuleY_95363Historic F5 AccountYou 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_95363Historic F5 AccountHere'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 } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects