Hello ,
You can use below iRule to achieve your requirement.
iRule1 - This will allow only www.test.com and rest all will be dropped on the VS.
when HTTP_REQUEST {
if {([HTTP::host] contains "www.test.com")
} {
log local0. "Allowed Hostname:[HTTP::host]"
} else {
drop
log local0. "“Invalid hostname: [HTTP::host]"
}
}
iRule - 2 - This will allow the required given host and will drop request coming for IP.
when HTTP_REQUEST {
if {([HTTP::host] contains "www.test.com") } {
log local0. "Allowed Hostname:[HTTP::host]"
} elseif {([HTTP::host] contains "10.10.10.10") }
{
drop
log local0. "“Invalid hostname: [HTTP::host]"
}
}
Additionally both irules will log each request and you can see logged requests under ltm files.
Hope it helps!