Forum Discussion
Issues to forward requests with 'start with' due to similar contexts under same domain
- Jul 15, 2022
Hi awakenings ,
you might use the regexp, but using globbing is probably less CPU intensive:
when HTTP_REQUEST { # Check the requested path (set to lowercase) # -glob: allow string pattern matching switch -glob -- [string tolower [HTTP::path]] { "/cali" - "/cali/" - "/cali/*" { log local0. "Matched pool 1 paths for [HTTP::uri]" pool pool1 } "/california" - "/california/" - "/california/*" { log local0. "Matched pool 2 paths for [HTTP::uri]" pool pool2 } default { log local0. "Hit default for [HTTP::uri]" pool pool_default } } }
This will send traffic to /cali and following segments to pool1 while traffic to /california and following segments will be forwarded to pool2.
UPDATE: I just realized I can add just /cali and that should be it
when HTTP_REQUEST { # Check the requested path (set to lowercase) # -glob: allow string pattern matching switch -glob -- [string tolower [HTTP::path]] { "/cali" -
"/cali/*" { log local0. "Matched pool 1 paths for [HTTP::uri]" pool pool1 } default { log local0. "Hit default for [HTTP::uri]" pool pool_default } } }
Thanks a lot! 🙂
Hi awakenings ,
you might use the regexp, but using globbing is probably less CPU intensive:
when HTTP_REQUEST {
# Check the requested path (set to lowercase)
# -glob: allow string pattern matching
switch -glob -- [string tolower [HTTP::path]] {
"/cali" -
"/cali/" -
"/cali/*" {
log local0. "Matched pool 1 paths for [HTTP::uri]"
pool pool1
}
"/california" -
"/california/" -
"/california/*" {
log local0. "Matched pool 2 paths for [HTTP::uri]"
pool pool2
}
default {
log local0. "Hit default for [HTTP::uri]"
pool pool_default
}
}
}
This will send traffic to /cali and following segments to pool1 while traffic to /california and following segments will be forwarded to pool2.
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