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

Gurdip_Sira_172's avatar
Gurdip_Sira_172
Icon for Nimbostratus rankNimbostratus
Sep 04, 2016

Redirect some users if they hit a certain uri

Hi,

I need to redirect certain users (client IP's) when they land to a certain page behind my virtual page.

Basically the below and also checking if the uri equals a page:

when HTTP_REQUEST {
    if { [class match [IP::client_addr] equals my_ip_dg] } {
        HTTP::redirect "http://10.200.200.200"
    }
}

However, my efforts have been in vain. What would I need to do to get this work?

3 Replies

  • You would have to explain what went wrong with your efforts to better assist you. I think this iRule should work:

    when HTTP_REQUEST {
        if { ([class match [IP::client_addr] eq my_ip_dg]) and ([HTTP::uri] eq "/abcd") } {
            HTTP::redirect "http://10.200.200.200/"
        }
    }
    
  • Hi Gurdip,

    unless you're using HTTP/1.0 without keep-alive sessions, then it would be more effective to evaluate the Client IP during the CLIENT_ACCEPTED event (triggered once at the beginning of each TCP session), store the

    [class match]
    results into a
    $variable
    and the use the stored results on each single HTTP_REQUEST.

    when CLIENT_ACCEPTED {
        if { [class match [IP::client_addr] equals my_ip_dg] } {
            set is_redirect 1
        } else {
            set is_redirect 0
        }
    }
    when HTTP_REQUEST {
        if { $is_redirect } then {
            if { [string tolower [HTTP::path]] equals "/somepath" } then {
                HTTP::redirect "http://10.200.200.200"
            }
        }
    }
    

    Note: Feel free to combinate the

    if $is_redirect
    and
    if HTTP::path
    conditions. I've splitted them just for demonstration purposes.

    Cheers, Kai