Forum Discussion
Need help building simple iRule
Hi Guys and Girls,
I need to create a simple iRule but sadly even simple is hard for me. The iRule should do the following:
If there is an http request which does not contain or equal business/portal.html it should be forwarded to pool 1, all other extensions business/portal.* (jpeg, gif, etc) should be forwarded to pool 2.
Can anyone help me with this?
Thanks!
- cjunior
Nacreous
Hello,
If you do not know how to create an iRule to this case, you can try an LTM policy and do the same thing, which can help you easely. https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-basics-11-6-0/6.htmlAnyway, You could do like this:
e.g. 1
when HTTP_REQUEST { Path is portal.hml or not begins with /business/portal. if { [HTTP::path] eq "/business/portal.html" || not ( [HTTP::path] starts_with "/business/portal." ) } { pool pool1 } else { pool pool2 } }
e.g. 2
when HTTP_REQUEST { Path begins with "/business/portal." and is not "/business/portal.html" if { [HTTP::path] starts_with "/business/portal." && [HTTP::path] ne "/business/portal.html" } { pool pool2 } else { pool pool1 } }
If url is case insensitive, you may need to change it into. e.g.
or[string tolower [HTTP::path]] eq "/test.html"
[string toupper [HTTP::path]] eq "/TEST.HTML"
Regards
- P_K
Altostratus
Might be helpful to Check this post https://devcentral.f5.com/questions/irule-to-redirect-traffic-based-on-path-and-uri
- Hectorm
Nimbostratus
here is the complete Irule. First make sure you set an variable with all lowercase of the path. Then compare the variable with the string in lower case.
when HTTP_REQUEST {
changing the path to lowercase set Vpath [string tolower [HTTP::path]] Path begins with "/business/portal.html" if { $Vpath contains "/business/portal.html" } { pool pool2 } else { pool pool1 }
}
- cjunior
Nacreous
Hi Hectorm,
If there is an http request which does not contain or equal business/portal.html it should be forwarded to pool 1, all other extensions business/portal. (jpeg, gif, etc) should be forwarded to pool 2.
Respectfully
here is the complete Irule. First make sure you set an variable with all lowercase of the path. Then compare the variable with the string in lower case.
when HTTP_REQUEST {
changing the path to lowercase set Vpath [string tolower [HTTP::path]] Path begins with "/business/portal.html" if { $Vpath contains "/business/portal.html" } { pool pool2 } else { pool pool1 }
}
- cjunior
Nacreous
Hi Hectorm,
If there is an http request which does not contain or equal business/portal.html it should be forwarded to pool 1, all other extensions business/portal. (jpeg, gif, etc) should be forwarded to pool 2.
Respectfully
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