Forum Discussion

THE_KING_249060's avatar
THE_KING_249060
Icon for Nimbostratus rankNimbostratus
Jun 27, 2016

iRules how to make the http_request seeping ip

I want to filter IP traffic and depends ip redirect me to certain pages . believes this code does not work.

 

I hope and I can help will thank .

 

when HTTP_REQUEST {
if { [IP::client_addr] equals "192.168.1.1" && "192.168.2.1" && "192.168.2.1" && "192.168.9.1" && [HTTP::uri] ends_with "/"
}
{
    pool Pool_App_Server
}
else
{
    drop
}
}
  • another example

    when HTTP_REQUEST { set var_ip [IP::client_addr]

    if { ($var_ip equals "192.168.2.4" or $var_ip equals "192.168.2.32" or $var_ip equals "192.168.1.2" or $var_ip equals "192.168.1.2") and ([HTTP::path] contains "Lynk.IVR.Mate") } {
        pool Pool_App_Server 
    } else {
        drop
    }
    

    }

  • I would recommend creating a datagroup and name it as "CLASS_ALLOWED_IP" and this will contain the 4 IP addresses you have specified:

    when HTTP_REQUEST {
    if { ([class match [IP::client_addr] eq CLASS_ALLOWED_IP]) and ([HTTP::uri] ends_with "/") } {
        pool Pool_App_Server
    } else {
        drop
    }
    }
    
  • another example

    when HTTP_REQUEST { set var_ip [IP::client_addr]

    if { ($var_ip equals "192.168.2.4" or $var_ip equals "192.168.2.32" or $var_ip equals "192.168.1.2" or $var_ip equals "192.168.1.2") and ([HTTP::path] contains "Lynk.IVR.Mate") } {
        pool Pool_App_Server 
    } else {
        drop
    }
    

    }