Forum Discussion

srantos_87030's avatar
srantos_87030
Icon for Nimbostratus rankNimbostratus
Jul 25, 2012

iRule to bypass default pool

Hello,

 

 

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.

 

 

 

4 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    srantos,

    Try adding some logging to see if this points you in the right direction, also added string tolower command to rule out uppercase / lowercase issues.

    when HTTP_REQUEST {
      if {[string tolower [HTTP::host]] contains "facebook"}{
      log local0. "HTTP Host: [HTTP::host]"
      pool isa_pool
      snat automap
    }
    } 

    Hope this helps,

    N
  • 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
    }
    }
    

    Aaron
  • I meant to include a link to more info on this:

     

     

    http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/oneconnect.html

     

     

    Aaron
  • Thank you hoolio and nathan.

     

     

    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.