Forum Discussion

Sachin_M_258695's avatar
Sachin_M_258695
Icon for Nimbostratus rankNimbostratus
Apr 20, 2017

Need an Irule

My Requirement is

 

When URI stats_with /api/superman and /api/xmen for it shud only allow to 1.1.1.1 and 2.2.2.2 and 3.3.3.3

 

thanks Sachin M

 

3 Replies

  • No, I don't understand that question. Can you draw a diagram?

     

    BR Jan

     

  • So, to add to Maneesh's excellent irule

    if { [HTTP::host] equals "www.xyz.com" } {
    switch -glob [string tolower [HTTP::uri]] {
       "/api/admin/" -
       "/api/account/" {
        if { ([class match [IP::client_addr] equals YOUR_DATA_GROUP_WHICH_HAS_3_IP's] )} {
        YOUR_API_POOL }
          else {
                reject }
    
        }
    }
    }
    }
    

    BR

    Jan

  • I will change the user input to lower case since the if statement is case sensitive. Also make sure you create the data group. To create the data group do the following: * go to local traffic/Irules/data group List * Click on Create * name:data_group1 * type: Address Under records Address: 10.1.1.5/32 <--This is the IP that you want to allow value : 10.1.1.5/32 Click add and repeat to enter other workstation when you are done click finished

    when HTTP_REQUEST {

    set Vuri [ string tolower [HTTP::uri]] set Vheader [ string tolower [HTTP::host]]

    if { $Vheader equals "www.xyz.com"} {
         switch -glob $Vuri {
                             "/api/account/" { 
                                                if { ([class match [IP::client_addr] equal data_group1 ] )} then { pool pool_name   }
                                                else { reject }
                                             }
                             "/api/admin/" { 
                                            if { ([class match [IP::client_addr] equal data_group1 ] )} then { pool pool_name   }
                                            else { reject }
                                            }   
                            default { pool pool_name }
    
         } 
    } 
    

    }