citizen_elah,
There's a few syntax errors (if's use curly braces, and else,elseif should be on the same line as closing curly brace) in there but by cleaning those your solution should work. Here are 3 possible rules (assuming the uri actually "ends with" the image type - otherwise use the "contains operator").
Here's a modified version of your solution
when HTTP_REQUEST {
if { [HTTP::host] equals "www.mydomain.com" } {
if { [HTTP::uri] ends_with ".jpg" } {
use pool Image_Svr_80
log "JPG file requested by [IP::client_addr]"
} elseif { [HTTP::uri] ends_with ".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]"
}
}
}
If you want to shorten this up without all the detailed logging for each image type, you could also do the following
when HTTP_REQUEST {
if { [HTTP::host] equals "www.mydomain.com" and \
[HTTP::uri] ends_with ".jpg" or \
[HTTP::uri] ends_with ".gif" } {
use pool Image_Svr_80
log "Image file requested by [IP::client_addr]"
} else {
use pool Main_Svr_80
log "Default LB Method for [IP::client_addr]"
}
}
If the group of image types increase, you might want to use a data group to store the image types to simplifly the script
class images {
".gif"
".jpg"
}
when HTTP_REQUEST {
if { [HTTP::host] equals "www.mydomain.com" and \
[matchclass [HTTP::uri] ends_with $::images] } {
use pool Image_Svr_80
log "Image file requested by [IP::client_addr]"
} else {
use pool Main_Svr_80
log "Default LB Method for [IP::client_addr]"
}
}
*Note that the "class image{...}" is not included in the rule but where declared externally as a data group list.
** Also note that the log lines are optional and can be included for trouble shooting.
-Joe