Converting irule from v9 to v11
The original irule is as below.
class https_rp_list {
"services.domain.com/path/ services-rp.domain.com/path/ services-rp_pool"
"services.domain.com/path/Enquiry/ services-rp.domain.com/path/Enquiry/ services-rp_pool"
}
when HTTP_REQUEST {
set rp_list $::https_rp_list
set orig_host [string tolower [HTTP::host]]
set orig_uri [HTTP::uri]
if {[HTTP::header exist "Accept-Encoding" ]} {
HTTP::header remove "Accept-Encoding"
if {$::DEBUG} {
log local0.debug "Header \"Accept-Encoding\" removed"
}
}
set matched_len 0
set matched_entry ""
foreach entry [set rp_list] {
set proxy_host_col [getfield $entry " " 1]
if {"$orig_host$orig_uri" starts_with $proxy_host_col } {
set new_len [string length $proxy_host_col]
if {$new_len > $matched_len} {
set matched_entry $entry
set matched_len $new_len
}
}
}
if {$matched_entry ne ""} {
set proxy_host_col [getfield $matched_entry " " 1]
set rp_host_col [getfield $matched_entry " " 2]
set rp_pool [getfield $matched_entry " " 3]
set proxy_host [getfield $proxy_host_col "/" 1]
set proxy_host_path [substr $proxy_host_col [string length $proxy_host]]
set rp_host [getfield $rp_host_col "/" 1]
set rp_path [substr $rp_host_col [string length $rp_host]]
if {$::DEBUG} {
log local0.debug "Rewrite Host from \"$orig_host\" -\> \"$rp_host\""
log local0.debug "Rewrite uri from \"$orig_uri\" -\> \"$rp_path[substr $orig_uri [string length $proxy_host_path]]\""
}
HTTP::uri $rp_path[substr $orig_uri [string length $proxy_host_path]]
HTTP::header replace "Host" $rp_host
pool $rp_pool
}
}
I rewrite it for v11.2.0 as below.
ltm data-group internal /Common/https_rp_list {
records {
"services.domain.com/path/ services-rp.domain.com/path/ services-rp_pool" { }
"services.domain.com/path/Enquiry/ services-rp.domain.com/path/Enquiry/ services-rp_pool" { }
}
type string
}
when HTTP_REQUEST {
set orig_host [string tolower [HTTP::host]]
set orig_uri [HTTP::uri]
if {[HTTP::header exist "Accept-Encoding" ]} {
HTTP::header remove "Accept-Encoding"
if {$::DEBUG} {
log local0.debug "Header \"Accept-Encoding\" removed"
}
}
set matched_len 0
set matched_entry ""
foreach entry [class get https_rp_list] {
set proxy_host_col [getfield $entry " " 1]
log local0. "proxy_host_col is $proxy_host_col"
if {"$orig_host$orig_uri" starts_with $proxy_host_col } {
set new_len [string length $proxy_host_col]
if {$new_len > $matched_len} {
set matched_entry $entry
set matched_len $new_len
}
log local0. "matched entry is $matched_entry"
}
}
}
However I see in the logs
[root@bigip1:Active:Standalone] config tail -f /var/log/ltm
Oct 15 17:15:35 tmm info tmm[6973]: Rule /Common/https_vserver : proxy_host_col is {services.domain.com/path/
Oct 15 17:15:35 tmm info tmm[6973]: Rule /Common/https_vserver : proxy_host_col is {services.domain.com/path/Enquiry/
I have no idea of why there is "{" attached at the beginning of the data group entry, and thus cannot match with the host. Can someone put me in the right direction?
Thanks in advance.