Forum Discussion
Host with Multiple URI
Hello, I have one listening IP for many application's, within the application some have requirement for datagroup to allow specific source IP's, but withing one application I have multiple uri's, therefor i was gone use switch say for "www.test.com" with the following uri's, allowed source ip go to this pool, for "www.test2.com with the following uri's with allowed source ip go to this pool and so forth, i was planing using two swicth statements
one for host and the second within the host for uri's i'm getting so much error is this supported
when HTTP_REQUEST { swicth [for host] "www.test.com" swicth for uri this will be inside the first swicth "/uri1" - "/uri2" - if the match class is datagroup source IP forward to this pool otherwise reject close the uri switch and use the second host
"www.test2.com swicth [for uri] list of uri's "/uri3" - "/uri4" - if the match class is datagroup named source IP2 forward to this pool/pools otherwise reject
5 Replies
- Cta_dev_116550
Nimbostratus
I got this resolved using the following,
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.test1.com” {
switch -glob [string tolower [HTTP::uri]] {
“/uri1" - “/uri2" - {if { ([class match [IP::remote_addr] equals $::Customer_Allowesd_IP]) } { return } }
}"www.test2.com” {
switch -glob [string tolower [HTTP::uri]] {
“/uri3" - “/uri4" - {if { ([class match [IP::remote_addr] equals $::Customer_Allowesd_IP]) } { return } }
}}
- nitass
Employee
$::Customer_Allowesd_IP
what version are you using? starting from 9.4.4, $:: is no longer needed to reference data group and it is cmp friendly now.
Class / Data Group List References 9.4.0 - 9.4.3, class reference not compatible as of 9.4.4, "::" and "$::" prefixes are no longer required to reference classes using findclass or matchclass. Classes are static and are therefore CMP compatible. There is no need to treat them as global objects. 10.0, matchclass / findclass deprecated in favor of new class commandCMP Compatibility
https://devcentral.f5.com/wiki/iRules.cmpcompatibility.ashx - Cta_dev_116550
Nimbostratus
thanks updated without the prefix
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.test1.com { switch -glob [string tolower [HTTP::uri]] {
“/uri1" - “/uri2" - {if { ([class match [IP::remote_addr] equals "Customer_Allowesd_IP"]) } { return } }
}switch -glob [string tolower [HTTP::uri]] {
“/uri1" - “/uri2" - {if { ([class match [IP::remote_addr] equals "Customer_Allowesd_IP"]) } { return } }
} }- nitass
Employee
if you do not use glob-style matching, you know, you can remove -glob option.
- Cta_dev_116550
Nimbostratus
Thank you, I'll do that I just wanted to make it work first as I was not sure if the entry with regards to DataGroups in multiple switch statement would be accepted.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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