Forum Discussion
i_rule help
We have 5 urls mapped to one IP (VS) under different LB pools & all are working on http. So if request is http://abc.com it redirects to its respective LB pool. one out of 5 url is moving to https now. So other 4 are still working on http with their resepctive LB pools. So i need to create a i-rule so only that url auto redirected to https & rest stay & work as is with their default LB pool on http.
Below is my proposed i-rule. Can anyone check if it is ok ?
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "abc.com" } { HTTP::respond 301 Location "https://abc.com[HTTP::uri]" }
Determine the Hostfieldset hostname [string tolower [HTTP::host]]
Determine ther original URI
set uri [string tolower [HTTP::uri]]
switch -glob $hostname {
"xyz.com" {
pool pool_xyz.com
}
default {
pool pool_jkl.com
}
}
}
- crodriguezRet. Employee
I would make the code after the redirect an "else" condition on the IF. For example:
when HTTP_REQUEST { if { [string tolower [HTTP::host] equals "abc.com" } { HTTP::respond 301 Location "https://abc.com[HTTP::uri]" } else { switch -glob [string tolower [HTTP::host]] { "xyz.com" { pool pool_xyz.com } default { pool pool_jkl.com } } } }
Other than that, the fact that the variable named uri does not appear to be used anywhere after it is set in your example, and there are only two checks for host name (if it is not abc.com) on the SWITCH rather than four, your code appears to be OK.
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