Forum Discussion

winifred_corbet's avatar
winifred_corbet
Icon for Nimbostratus rankNimbostratus
May 20, 2010

allow access to URL by specific IP range - all others rejected

For a specific URL I need to allow access to URL only to our internal IP range, all other IP addresses need to be rejected.

 

 

Something along these lines, but clearly this is not correct. Can anyone help?

 

 

when HTTP_REQUEST {

 

{[HTTP::uri] "special_file"}

 

{ [IP::addr [IP::remote_addr] equals 72.xxx.xxx.0/72.xxx.xxx.26 ] } {

 

reject

 

}

 

}

 

  • Sorry...I had to edit my first post and the format is never the same after an edit:

    Go into your LTM under iRules -> Data Group List

    Create -> Name it -> Type Address

    Add the IP Addresses (or configure the Network Range) that you want to allow (Then replace the "PoolOfAllowedAddresses" with the name of the group you created).

    
    when HTTP_REQUEST {
    if { [HTTP::host] equals "www.website.com" and ([matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
    pool poolofallowedservers
    }
    else {
    reject
    }
    }
    

    This is designed to Accept anything in the Data Group and Reject everything else.
  • Another question:

     

    I need to specify if a 'specific" URL is hit and they are *not* coming from the IP range called out in 'Data group List" I need to reject them.

     

     

    So,

     

    If "a Specific Full URL" and *not* coming from "data Group List" --- reject them
  • If you need to be extremely specific you can have it check the URI as well.

    
    when HTTP_REQUEST {
        if { [HTTP::host] equals "www.website.com" and [HTTP::uri] equals "/somethingspecific/index.html" and [matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
            pool poolofallowedservers
        }
        else {
            reject
        }
    }
    

    If you want exclusive over inclusive you can make a few modifications:

    
    when HTTP_REQUEST {
        if { [HTTP::host] equals "www.website.com" and [HTTP::uri] equals "/somethingspecific/index.html" and !([matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
            reject
        }
        else {
            pool poolofallowedservers
        }
    }
    
    • Ahmad_Ghazal_17's avatar
      Ahmad_Ghazal_17
      Icon for Nimbostratus rankNimbostratus
      Hi, what the following line means, and what it's used for? pool poolofallowedservers
    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      poolofallowedservers is pool name. the command does send traffic to that pool.
  • If you need to be extremely specific you can have it check the URI as well.

    
    when HTTP_REQUEST {
        if { [HTTP::host] equals "www.website.com" and [HTTP::uri] equals "/somethingspecific/index.html" and [matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
            pool poolofallowedservers
        }
        else {
            reject
        }
    }
    

    If you want exclusive over inclusive you can make a few modifications:

    
    when HTTP_REQUEST {
        if { [HTTP::host] equals "www.website.com" and [HTTP::uri] equals "/somethingspecific/index.html" and !([matchclass [IP::remote_addr] equals $::PoolOfAllowedAddresses ]) } {
            reject
        }
        else {
            pool poolofallowedservers
        }
    }
    
    • Ahmad_Ghazal_17's avatar
      Ahmad_Ghazal_17
      Icon for Nimbostratus rankNimbostratus
      Hi, what the following line means, and what it's used for? pool poolofallowedservers
    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      poolofallowedservers is pool name. the command does send traffic to that pool.