Forum Discussion

SSHSSH_97332's avatar
SSHSSH_97332
Icon for Nimbostratus rankNimbostratus
Jan 25, 2012

Top Domains Selection

i need to do the below :

Users router will direct all HTTP traffic to external interface( external vlan ) of my F5 LTM . on this external vlan i have Vs listening for HTTP traffic & i need to do the below :

 

*if tarffic is for website www.youtube.com , www.4shared.com or www.rapidshare.com >>>>>> VS will balance it to Pool consisting of my cache servers

 

*if any other website >>>>>>forward directly to the Gateway router ( to the internet ) & no cashing happens

 

 

 

  • Hi SSHSSH,

    Are client's using the LTM virtual as a web proxy or connecting transparently? ie, do clients use a fully qualified URL in the URI like:

    GET http://www.example.com/file.ext?param=value

    If so, you can use something like this:

    
    when CLIENT_ACCEPTED {
     Save VS default pool name
    set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
    
    switch  [string tolower [URI::host [HTTP::uri]]] {
    youtube.com -
    www.youtube.com -
    4shared.com -
    www.4shared.com -
    rapidshare.com -
    www.rapidshare.com {
    pool cache_pool
    }
    default {
    pool $default_pool
    }
    }
    }
    

    Aaron
  •  

    Q1:****Vs is 0.0.0.0 & port 80 . router will forward HTTP traffic to LTM so i think this means that it is transparent & i can use what you provided , right ?

     

     

    Q2:****Also i cannot understand the part

     

    when CLIENT_ACCEPTED {

     

    Save VS default pool name

     

    set default_pool [LB::server pool]

     

     

    Q3:*****Why is not it only the below :

     

     

    when HTTP_REQUEST {

     

     

    switch [string tolower [URI::host [HTTP::uri]]] {

     

    youtube.com -

     

    www.youtube.com -

     

    4shared.com -

     

    www.4shared.com -

     

    rapidshare.com -

     

    www.rapidshare.com {

     

    pool cache_pool

     

    }

     

    default {

     

    pool $default_pool

     

    }

     

    }

     

    }

     

     

     

    Q4:****Also :

     

    switch [string tolower [URI::host [HTTP::uri]]]

     

    URI::host : looks at host part of HTTP , but what is need of [HTTP::uri] ?

     

    string tolower : what does this do ?

     

     

     

     

     

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    SSHSSH

     

     

    Q2) set default_pool [LB::server pool] = this is setting up a variable (default_pool) that is referenced further down the iRule. So it will record what the default pool is associated with the VS and then refer requests onto this if they're not in the list of URLs. So the command would then be "pool http_pool" or whatever is the pool's name.

     

     

    Q4) string tolower converts the whole host and URI into lower case - so, in effect, makes the switch command case insensitive. You probably don't need the HTTP::uri but I would use it for neatness so the whole URL is interrogated. May be wrong of course.

     

     

    I'm not an iRule expert I'm afraid but hope this is useful / correct.

     

     

    N
  • That's a great explanation Nathan. One more note: I used URI::host to parse the host name from a fully qualified URL in the URI. If the client is making requests through LTM to a web proxy, they would use a fully qualified URI. Else, if they're going through a transparent proxy, the URI would be relative and you'd want to check for the host name of the request in the host header using [HTTP::host] instead of [URI::host [HTTP::uri]].

     

     

    Aaron