Forum Discussion
cames1_233757
Nimbostratus
Feb 02, 2016Wildcard for Host Subdomains inside a Switch?
Is there a way to use wildcards to match any subdomain for Host entries inside a switch?
So, for example:
switch -glob [string tolower [HTTP::host]] {
"*.domain.com" { Do Something }
...
mo_99289
Feb 02, 2016Historic F5 Account
hope this could help
when HTTP_REQUEST {
log local0. "Host is [string tolower [HTTP::host]]"
switch -regexp [string tolower [HTTP::host]] {
.*\.a.com {
log local0. "*.a.com"
}
.*\.b.com {
log local0. "*.b.com"
}
default {
log local0. "default domain"
}
}
simple test:
for host in web.a.com web.b.com web.c.coom; do curl -o /dev/null -H "Host: $host" http://10.2.22.183/; done
ltm log:
Feb 2 17:28:00 ve3 info tmm1[32273]: Rule /Common/irule_http_request : Host is web.a.com
Feb 2 17:28:00 ve3 info tmm1[32273]: Rule /Common/irule_http_request : *.a.com
Feb 2 17:28:00 ve3 info tmm[32273]: Rule /Common/irule_http_request : Host is web.b.com
Feb 2 17:28:00 ve3 info tmm[32273]: Rule /Common/irule_http_request : *.b.com
Feb 2 17:28:00 ve3 info tmm1[32273]: Rule /Common/irule_http_request : Host is web.c.coom
Feb 2 17:28:00 ve3 info tmm1[32273]: Rule /Common/irule_http_request : default domain
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