Forum Discussion
Patrick_Stiever
Sep 09, 2011Nimbostratus
iRules amatuer What does this iRule do?
Hello all,
I do not have much experience with iRules, and I am hoping some here can give me an idea what this iRule is doing:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/onlineserv/HB" ||
[HTTP::uri] starts_with "/beta/HB" ||
[HTTP::uri] starts_with "/preprod/HB" }
{
Lookup the host based on the HTTP host header
log local0. "host = '[HTTP::host]'"
set ibHost [class lookup [HTTP::host] $::USP_IB_REDIRECT_DG]
if { $ibHost != "" }
{
log local0. "ibHost found: '$ibHost'"
node $ibHost
}
else
{
log local0. "ibHost not found"
HTTP::respond 404
}
}
else
{
SSL::disable serverside
}
}
Thank you.
- nitassEmployeeabove URI list i.e. /onlineserv/HB, /beta/HB, /preprod/HB will be sent to specific HTTPS server (node) which is defined in USP_IB_REDIRECT_DG data group (class).
- hooleylistCirrostratusYou'll need to remove the $:: prefix from the datagroup name reference in the iRule:
- hooleylistCirrostratusHere's an updated version which uses a switch statement to check the URI and corrects the datagroup reference:
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/onlineserv/HB" - "/beta/HB*" - "/preprod/HB*" { Lookup the host based on the HTTP host header log local0. "host = '[HTTP::host]'" Check if the host header exists and isn't an IP if {[string match -nocase {*[a-z]*} [HTTP::host]]}{ set ibHost [class lookup [HTTP::host] USP_IB_REDIRECT_DG] if { $ibHost != "" } { log local0. "ibHost found: '$ibHost'" node $ibHost } else { log local0. "ibHost not found" HTTP::respond 404 } } else { SSL::disable serverside } } default { Default action is to use the VS default pool for non-matching URIs } } }
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