Forum Discussion
Error while loading iRule
Any idea why this rule loads:
ltm rule LOOKUP_LB_Policy {
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::host]] contains HTTP_URL_RLSE_LOOKUP_Class]} {
pool HPVTIBRLSEPROXY_Farm
} elseif { [class match [string tolower [HTTP::host]] contains HTTP_URL_LOOKUP_Class]} {
pool HPVTIBPROXY_Farm
} else {
drop
}
}
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
if { [HTTP::header exists Location] } {
HTTP::header replace Location [string map {"http://first.domain.com" "https://first.domain.com"} [HTTP::header Location]]
}
}
}
}
while this one doesn't, with an error message "01070151:3: Rule [/Common/PROD_SSL_LB_Policy] error: /Common/PROD_SSL_LB_Policy:41: error: [braces are required around the expression][when HTTP_RESPONSE {"
ltm rule PROD_SSL_LB_Policy {
when HTTP_REQUEST {
if { [class match [string tolower [HTTP::host]] contains HTTP_URL_w1HBFCOMAU_Class]} {
pool HPVCMSAPP_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_GIOS_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HBFDECLARATION_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_ONLINETRAVELWEB_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_WEBFORMS_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_ONLINECLAIM_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HIOS_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HCFTRAVEL_CLASS] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_PROVIDERCENTRE_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HOSPITALADMIN_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HOSPITAL_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_MYHBF_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_HBFATHOME] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_TRAVEL-INSURANCE_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::uri]] contains HTTP_URL_DDTRAVEL_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::host]] contains HTTP_URL_MIHBFCOMAU_Class] } {
pool PROD_CMS_Farm
} elseif { [class match [string tolower [HTTP::host]] contains HTTP_BAD_URL_PROD_Class] } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
} else {
pool PROD_CMS_Farm
}
}
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
if { [HTTP::header exists Location] } {
if { [string tolower [HTTP::header Location]] equals “http://second.domain.com” } {
HTTP::header replace Location [string map {"http://second.comain.com.au" "https://second.domain.com.au"} [HTTP::header Location]]
} elseif { [string tolower [HTTP::header Location]] equals “http://third.domain.com.au” } {
HTTP::header replace Location [string map {"http://third.domain.com.au" "https://third.domain.com.au"} [HTTP::header Location]]
}
}
}
}
}
I've checked that there is closure on all braces and brackets, and that I'm allowed to use all of my commands in the HTTP_RESPONSE context, but after that, I'm drawing a blank.
Pardon the somewhat clunky setup, it's a configuration migration and I'm making the rule logic mirror the Cisco policy map behavior the client currently has.
2 Replies
- pete_71470
Cirrostratus
It looks like a right curly brace is missing after the final else:
} else { pool PROD_CMS_Farmshould read:
} else { pool PROD_CMS_Farm } - rob_carr
Cirrocumulus
It turns out to have been some 'smart' quotes in the line where I check the content of the Location header. Replace those, and it all works.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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