Forum Discussion
JackRodriguez
Nimbostratus
Apr 19, 2016iRule to define pool names based on URI mapped to a value in a data group.
I have a need to configure a iRule that can take a portion of the URI and search a data group and then take the mapped value and use that in the creation of the pool name. I am not a coder and I thou...
cjunior
Nacreous
Apr 20, 2016Hi, according to documentation, "class match" is more performatic than "matchclass".
https://devcentral.f5.com/wiki/irules.class.ashxI think you did a good job and I just made some changes which sounds better to me.
when HTTP_REQUEST {
set value [class match -value [string tolower [HTTP::path]] contains APP_DEV_uri_pool_map]
if { $value ne "" } {
pool APP-BW-DEV-$value
} else {
log local0. "uri-map-lookup-failed: from: [IP::remote_addr] for request: [HTTP::host] [HTTP::uri]"
HTTP::respond 404 content {
Not found
Not found
The requested page or resource was not found.
}
}
unset value
}
Maybe it should be improved with pool selection check.
https://devcentral.f5.com/articles/irules-101-07-catchwhen HTTP_REQUEST {
set value [class match -value [string tolower [HTTP::path]] contains APP_DEV_uri_pool_map]
if { $value ne "" } {
if { [catch { pool APP-BW-DEV-$value }] } {
log local0.warn "uri-map-selection-failed: from: [IP::remote_addr] for request: [HTTP::host] [HTTP::uri] pool: APP-BW-DEV-$value"
HTTP::respond 500 content {
Internal Server Error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
}
}
} else {
log local0.notice "uri-map-lookup-failed: from: [IP::remote_addr] for request: [HTTP::host] [HTTP::uri]"
HTTP::respond 404 content {
Not found
Not found
The requested page or resource was not found.
}
}
unset value
}
Respectfully,
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