Trying to combine 3 irules together or look for a better way to execute
Hi folks. I am a new F5 admin and I was having some issues to trying to get 3 irules to run nicely with each other on the same virtual server. My goals are this:
irule1: If you access a specific url on the virtual server and match a DG of allowed ip addresses, you get redirected to the pool. If you aren't in the DG you get redirected to a friendly forbidden page hosted on the F5.
if {( [string tolower [HTTP::host]] equals "abc.com" and [matchclass [IP::remote_addr] equals $::abc_allow_dg ]) {
pool GSENT.abc.com
}
else {
HTTP::respond 200 content [ifile get abc_ip_forbidden]
}
}
irule2: This is for name based hosting. My company hosts about a 100 sites on a single virtual server to save public IPs. Each website has its own pool and own HTTP monitor. If you access a site that is listed in a data group you will be directed to your corresponding pool. If the URL and pool are not in the DG the request is discarded.
when HTTP_REQUEST {
good-DG-Prod is a string data-group where the entries are name:value pairs
name is the requested HTTP host header, value is the associated pool-name
check the requested HTTP host header against entries in data-group good-DG-Prod
if { [class match [string tolower [HTTP::host]] equals good-DG-Prod ] } {
if the HTTP host header is in good-DG-Prod
send the request to the pool associated with the good-DG-Prod entry
pool [class match -value [string tolower [HTTP::host]] equals good-DG-Prod ]
} else {
drop the request if the host header is not in good-DG-Prod
drop
}
}
irule3: This is a basic maintenance page. If all pool members are down for a particular website then you get a maintenance page.
when HTTP_REQUEST {
if { [active_members [LB::server pool]] == 0} {
switch [string tolower [HTTP::uri]] {
"/" {
HTTP::respond 200 content [ifile get testapp_index_txt]
}
"/f5b_mini.png" {
HTTP::respond 200 content [ifile get testapp_f5ball_img]
}
}
}
}
I can apply irule(s) 2 and 3 to a single virtual server and they seem to work correctly together with irule 2 at top of the list. If I apply all 3 rules to the VS like this 1,2,3. The first irule doesn't execute correctly.
Any help from or suggestions would be greatly appreciated.
Thanks,
Kevin