For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Mazen2006_14317's avatar
Mazen2006_14317
Icon for Nimbostratus rankNimbostratus
Mar 27, 2014

iRule problem: what is the matter whith this iRule?

when HTTP_REQUEST 
{
    if {  [string tolower [HTTP::uri]] starts_with "/necpf/vod-i1-64/cpprospect/" } 
    {
                if { [string tolower [HTTP::uri]] ends_with "/media_cpa/sfr/cpprospect/maintenence/maintenance.jpg" } 
                {
                               [HTTP::redirect] http://172.19.224.62:9000/media_app/sfr/cpprospect/maintenance/maintenance.jpg
                }
        else {
                               [HTTP::redirect] http://172.19.224.62:9000/media_app/sfr/cpprospect/maintenance/maintenance.html
            }
    }

}
when HTTP_RESPONSE {
                    if {  [string tolower [HTTP::uri]] contains "/media_app/sfr/cpprospect/maintenence/" } 
                            {
                               [HTTP::uri] "/NECPF/vod-i1-64/cpprospect [string tolower [HTTP::uri]]"

                            if {[string tolower [HTTP::uri]] ends_with "/media_cpa/sfr/cpprospect/maintenance/maintenance.html"}
                            {
                               [HTTP::status] = 302
                            }
                        }
}

6 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Mazen2006,

     

    The obvious issue is you cannot call the HTTP::uri command in event HTTP_RESPONSE.

     

    See the wiki to confirm: HTTP_RESPONSE

     

    Not sure how you could achieve what you need to achieve, however, but I hope I can get you moving in the right direction. There will be better iRulers than I on DC that can help.

     

    N

     

  • It would be very helpful if you could give a quick explanation of what you're trying to accomplish.

     

    when HTTP_REQUEST {
        if {  [string tolower [HTTP::uri]] starts_with "/necpf/vod-i1-64/cpprospect/" } {
            if { [string tolower [HTTP::uri]] ends_with "/media_cpa/sfr/cpprospect/maintenence/maintenance.jpg" } {
                HTTP::redirect "http://172.19.224.62:9000/media_app/sfr/cpprospect/maintenance/maintenance.jpg"
            } else {
                HTTP::redirect "http://172.19.224.62:9000/media_app/sfr/cpprospect/maintenance/maintenance.html"
            }
        }
    }

    This section basically says, if the URI starts with "/necpf/vod-i1-64/cpprospect/" and ends with "/media_cpa/sfr/cpprospect/maintenence/maintenance.jpg", do a browser redirect to http://172.19.224.62:9000 with a new URI. This IP is an RFC 1918 internal address, so is this an internal network where users have access to this IP directly, or do you mean to pass the traffic through a BIG-IP virtual server? If the latter, an HTTP redirect causes the browser to make a request to a specified location. Given that this server is likely behind the BIG-IP and a virtual server, you'll probably want to create a pool for 172.19.224.62:9000 and use a pool statement to route the traffic:

     

    pool maintenance_pool
    HTTP::uri "/media_app/sfr/cpprospect/maintenance/maintenance.jpg"

    Your HTTP_RESPONSE code is a little confusing. First, as Nathan states, you cannot use HTTP::uri in this event because this information isn't part of an HTTP response. The only places you'll generally see URIs in an HTTP response is in a redirect Location header, or in the HTTP payload itself, in which case there are different approaches for evaluating each.

     

  • giltjr's avatar
    giltjr
    Icon for Nimbostratus rankNimbostratus

    If you want to do something with the URI in a respond you need to set it as a variable in HTTP_REQUEST, something like:

     

    request_URI = [HTTP::uri]

     

    Then in the HTTP_RESPONSE you can check it using $request_URI.

     

    However, if you are trying to do a redirect in HTTP_RESPONSE, I would assume that you really want to do it base on something the server sent, not based on a request the client sent. If you are doing something based on what the client sent, that would be done in HTTP_REQUEST.

     

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    1. You're doing case insensitive comparisons on URI's when URI's are case sensitive
    2. The redirects aren't in quotes...

    Are we checking for syntax (The errors trying to save will tell you that) or function (What is the aim exactly?)

     

    H

     

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus

    To be reliable, you'd have to redirect to a page that loads a jpg as well... If the client is expecting text/html and gets pack a jpg, it may not like it (Think it would depend on the client).

     

    H