Forum Discussion
Mike_73765
Nimbostratus
Mar 03, 2010Block 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?
Th...
hoolio
Cirrostratus
Mar 03, 2010Hi 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
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects