Forum Discussion
Daniel_Abrahams
Nimbostratus
Feb 18, 2021Require host header
Hi, Is there a setting/iRule that makes it so that host header is required for clients to be able to connect to server. For example User enters https://www.test.com he will be able to connec...
Mayur_Sutare
MVP
Feb 18, 2021Hello ,
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!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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