Forum Discussion

Mike_73765's avatar
Mike_73765
Icon for Nimbostratus rankNimbostratus
Mar 03, 2010

Block users from using ip instead of url

I have a https VS, where i want to block users from connecting if they type in the ip address instead of the url. can i do this without using an irule? if so, how...custom profile?

 

 

Thanks,

 

Mike

2 Replies

  • Hi Mike,

    With 9.4 or higher, you could use an HTTP class with a host header filter that matches on IP addresses with a regex. The action on the class could be to use a pool with a dummy pool member or an HTTP redirect. The regex could be:

    [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}

    Or this might also work depending on the regex parser:

    (?:[0-9]{1,3}\.){3}[0-9]{1,3}

    Or you could be less exact and more efficient and set the host header to match a string with three periods:

    *.*.*.*

    This assumes your web site shouldn't ever get referenced using more than the three fields in a subdomain (www.example.com and not sub1.sub2.example.com or anything with more fields).

    You could also use an iRule to do this. In that case, it would be relatively simple and efficient to use string match or scan to check the host header value isn't an IP:

     
     when HTTP_REQUEST { 
      
         Check if the host header contains one or more alpha characters 
        if {not ([string match -nocase {*[a-z]*} [HTTP::host]])}{ 
      
            Host was either empty or an IP address, take some action 
        } 
     } 
     

    Aaron
  • thanks Aaron.

     

     

    So if i want to drop the request, if they try to access by ip, what would the action syntax look like?