Forum Discussion

Jean_42123's avatar
Jean_42123
Icon for Nimbostratus rankNimbostratus
May 11, 2010

iRule - HTTP Request Redirection - HELP

Hi Guys, I am really frustrated and i would like your help to complete the below script. The target of the script is to check a list of URI. In case of any match with the list, we would like to redirect the HTTP request to our pool of proxy servers. if not, we would like to redirect the request directly to the internet. Below is part of the script I need your help to complete the missing part mentioned below: your prompt reply is highly appreciated. Thank you Jean when HTTP_REQUEST { if {[HTTP::uri] contains "http://wap.hungama.com/" } { pool proxy-pool } else { missing part} }

9 Replies

  • Hi Jean,

    If you had a URL: http://www.website.com/subdirectory/index.html

    [HTTP::host] is the first portion of your URL - www.website.com

    [HTTP::uri] is everything trailing (including the "/") - /subdirectory/index.html

    Wiki Pages:

    HOST: http://devcentral.f5.com/Wiki/default.aspx/iRules.HTTP__host

    URI: http://devcentral.f5.com/Wiki/default.aspx/iRules.HTTP__uri

    or

    PATH: http://devcentral.f5.com/Wiki/default.aspx/iRules.HTTP__path

    
    when HTTP_REQUEST {
    if { [HTTP::host] equals "wap.hungama.com" } {
    pool desired.server.pool
    }
    else {
    HTTP::redirect "http://www.google.com"
    }
    }
    

    Hope this helps.
  • Hi Michael,

     

     

    Thx for your message. I have noted the difference between host and URI.

     

    But what if the user tried to access www.yahoo.com ( or any website that doesn't match the if statement ) he would be redirected in this case to www.google.com ! no ?

     

    please advise.

     

     

    Jean
  • Correct.

     

     

    With the iRule I posted you would be redirected to www.google.com if the [HTTP::host] did not match.

     

     

    Is that not what you wanted?
  • Hi Michael,

     

     

    No, let me rephrase it again. if the request is www.yahoo.com I still want to go direclty to the internet to www.yahoo.com without being redirected to our proxies.

     

     

    let me know if you need more clarifications.

     

     

    thanks

     

     

    Jean
  • Matt,

     

     

    thanks for your prompt reply.

     

     

    Actually I have implemented the above i-rule as you have mentioned. I was able able to redirect the traffic to my proxies when there is a match but unfortunately the request is timing out when there is no match !!

     

     

    P.S: There is a default route defined on the Big IP.

     

     

    what could be the issue in this case??

     

     

    thanks again for your support.

     

     

    Jean
  • A couple of things may be going on. Do you have a SNAT associated with this virtual server by chance? If not, that may be worth a try. Pay close attention to the source IP of the request along the path and be sure that at some point it'll be translated correctly as it goes out into the wild. If your requests are timing out, is it possible that you've got private, non routable source addresses going outbound? Do your proxies source the traffic differently? If so, how?

     

     

    -Matt
  • Matt,

     

     

    yes there is a SNAT defined but it's associated with the pool and not to the virtual server. Is there any difference?

     

     

    let me know...

     

     

  • I had a look at the config. This VS is listening on port 8080. The forward statement in irule will not do port translation by default.

     

    So, try and create a pool on port 80, and instead of forward statement use pool new_pool ..