Forum Discussion
Irule question about switch -glob $host
Hello
I'm confused of what this irule does. Could someone explain?
when HTTP_REQUEST {
set host [HTTP::header host]
switch -glob $host {
"dc.bangkokair.com" {pool cp-2sg-as-t1-mingo-prod_pool_81xx }
"sws-pg.as.havail.sabre.com" {pool cp-2sg-as-t1-mingo-prod_pool_81xx }
default {
pool cp-2sg-as-t1-mingo-prod_pool_81xx
}
}
Assuming that xx represent different numbers then you can best explain it as..
when HTTP_REQUEST { set host [HTTP::header host] switch -glob $host {
Take the host entry and use it as a switch statement target
"dc.bangkokair.com" {pool cp-2sg-as-t1-mingo-prod_pool_81xx } "sws-pg.as.havail.sabre.com" {pool cp-2sg-as-t1-mingo-prod_pool_81xx } default { pool cp-2sg-as-t1-mingo-prod_pool_81xx }
Search for the following and provide the appropriate pool of servers...
- Matched dc.bankokair.com select pool cp-2sg-as-t1-mingo-prod_pool_81xx.
- Matched sws-pg.as.havail.sabre.com select pool cp-2sg-as-t1-mingo-prod_pool_81xx.
- If no matches select pool cp-2sg-as-t1-mingo-prod_pool_81xx
The switch -glob allows you to do simple pattern matching as follows...
Ends with "*.bankokair.com"
Starts with "www.*" Contains "*.bankokair.*"Note the periods (.) have no special meaning. They just represent that character.
From a high level perspective, if they type in http(s)://dc.bangkokair.com/* the name is mapped to the IP address (or external NAT) of this virtual server. Same for http(s)://sws-pg.as.havail.sabre.com/* but it will accept any name given the default pool selection.
Recent Discussions
Related Content
* 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