Forum Discussion
Rusty_Hale_8009
Nimbostratus
Apr 05, 2005iRule conversion from 4.X to V9
I have made an attempt to convert an iRule to V9. Could someone please check my syntax? I would really appreciate it. Thanks.
if { [HTTP::host]
rule Image_Rule {
...
JRahm
Admin
Apr 05, 2005Here's my crack, though I don't have a box currently to test on. I'm sure the and/or logic can be reduced, I'm curious if that would make the rule more processor efficient?
Unless jpg or gif would be anywhere else in your URL, I'd suggest using contains instead of ends_with. In the event a trailing / is appended in the uri, the rule wouldn't match. I added logging that you can use strictly while working on your rules.
rule Image_Rule {
when HTTP_REQUEST
{
if ( [HTTP::host} equals "www.mydomain.com" ) {
if ( [HTTP::uri] contains "jpg" ) {
use pool Image_Svr_80
log "JPG file requested by [IP::client_addr]"
}
elseif ( [HTTP::uri] contains "gif" ) {
use pool Image_Svr_80
log "GIF file requested by [IP::client_addr]"
}
else {
use pool Main_Svr_80
log "Default LB Method for [IP::client_addr]"
}
}
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