Forum Discussion

awakenings's avatar
awakenings
Icon for Nimbostratus rankNimbostratus
Jul 14, 2022

Issues to forward requests with 'start with' due to similar contexts under same domain

Hi everybody, A network request that seemed to be simple is giving some trouble to our network team, I'd appreciate some help. Here's a summary of the rules to be put in place: 1) example.domain.c...
  • StephanManthey's avatar
    StephanManthey
    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.