I am using a virtual server to load-balance HTTP traffic from customers to a pool of traffic servers. I need an iRule to bypass this pool and send the HTTP requests to an Internet proxy with IP address 172.19.44.13 when the HTTP request contains the string “facebook” in the Host header.
I am using this iRule:
when HTTP_REQUEST {
if {[HTTP::host] contains “facebook”} {
pool isa_pool
snat automap
}
}
I am testing and I notice that as soon as this iRule matches when I visit “www.facebook.com” for example, it will match any other HTTP request after the first correct match. For example, if I visit “www.google.com” after I visit “www.facebook.com” the iRule will match for google as well!
Can you think what is wrong? Thank you in advance.
This is the default connection based load balancing behavior. To have LTM load balance per HTTP request you can either add a OneConnect profile to the VS or specify a pool in every case when you’re specifying a pool for any case. Here’s an example of the latter:
when CLIENT_ACCEPTED {
Save the name of the VS default pool before it is changed in this iRule
set default_pool [LB::server pool]
}
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] contains "facebook"}{
log local0. "Using isa pool for HTTP Host: [HTTP::host]"
pool isa_pool
snat automap
} else {
log local0. "Using default pool $default_pool for HTTP Host: [HTTP::host]"
pool $default_pool
snat none
}
}
I have used the log and else statements you advised and it works now. In /var/log/ltm I can see that the correct pool is selected for every http request.
However I still see some traffic with tcpdump to the isa pool when browsing to “www.google.com” but they are only “tcp fin-ack” messages. I assume that they are just expired sessions from previous iRule matches.