Forum Discussion
abeny_894
Nimbostratus
Dec 03, 2008How to combine two iRules into one?
Dears,
First of all, I would like to say thanks to all of you that I have learned much on iRules in here.
I have a question on how can I combine separate iRules into ONE? The situation is I have got several separate iRules on hand as below: They are all using HTTP_REQUEST, the different is iRules One is using [HTTP::host], iRules Two is using [HTTP::uri], iRules Three is using [HTTP::host][HTTP::uri]. If test separatly, they all work fine for apply to One VS.
As the real case may involve ALL of the below case in one VS, I would like to ask can they be combine into one? How can I do this?? Thank you very much for you guys help.
___________________________________________________________________________________
****iRules One****
when HTTP_REQUEST {
switch [HTTP::host] {
abc.com {
log local0. "hit abc.com"
Details scriptes
xyz.com {
log local0. "hit xyz.com"
Details scripts
****iRules Two****
when HTTP_REQUEST {
switch [HTTP::uri] {
/app1/index.html {
log local0. "hit abc/app1/index.html"
Details scriptes
/app2/index.html {
log local0. "hit xyz/app1/index.html"
Details scriptes
****iRules Three****
when HTTP_REQUEST {
switch [HTTP::host][HTTP::uri] {
abc.com/app1/index.html {
log local0. "hit abc.com"
Details scriptes
xyz.com/app2/index.html {
log local0. "hit xyz.com"
Details scripts
___________________________________________________________________________________
- Colin_Walker_12Historic F5 AccountWhat you would probably want to do is combine all of the cases into one large switch. You could use switch -glob [HTTP::host][HTTP::uri] to accomplish this. Then for the host only matches use something like "abc.com*" for the match, and for the uri only matches use "*/app1/index.html". Then you would leave the host and uri comparisons the same, and one switch should handle all of the above cases.
- abeny_894
Nimbostratus
Sorry that I can't make the combine irules well. Always got error... Would you kindly help to give me a sample look like?? Thanks a lot. - abeny_894
Nimbostratus
Colin, I have combine the iRules into one and shown as below: - abeny_894
Nimbostratus
Thanks a lot Colin. You really help me lots. For real situation, i need check the pool status in every condition, but i found that it seems can't work under "switch -glob", it prompt error " [parse error: PARSE syntax 924 {syntax error in expression " How can I use switch -glob to switch case also monitor the pool status at the same time?? - abeny_894
Nimbostratus
Hi Colin, - abeny_894
Nimbostratus
AnyBody can help? - hwidjaja_37598
Altostratus
Try this:when HTTP_REQUEST { switch -glob "[HTTP::host][HTTP::uri]" { "test1.f5lab.com*" {
- hoolio
Cirrostratus
If you're only checking the host in the switch statement, you could leave off the -glob flag and the URI:switch [string tolower [HTTP::host]] { "test1.f5lab.com" {
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