Forum Discussion

lorenze's avatar
lorenze
Icon for Altocumulus rankAltocumulus
Aug 10, 2020

Redirect multiple CNAME to a pool

Hello,

 

Just want to ask for your thoughts on what would be the quickest way to redirect multiple CNAME for our website to specific pool?

For instance, we have cname1.site.com, cname2.site.com and so on and want to redirect them all into a specific pool.

 

Thanks for you input.

 

Best

  • Should be something like this?

    when HTTP_REQUEST {
     
    if { [HTTP::host] eq "cname1.site.com" "cname2.site.com} {
     
    pool pool_name
     
    }
     
    }
    • Simon_Blakely's avatar
      Simon_Blakely
      Icon for Employee rankEmployee

      It will be easier to manage if you create a datagroup (type string) to hold the CNAMES, and match against the datagroup.

      when HTTP_REQUEST {
      # cname_dg is a datagroup of type string containing matching cnames
       
         if { [HTTP::host] equals cname_dg} {
           pool pool_name
         }
      }
       
      • lorenze's avatar
        lorenze
        Icon for Altocumulus rankAltocumulus

         ,

         

        Thanks for pointing that out. I haven't really think of it or if that is even possible. Quick question though, Does the string and value on creating DG needs to match or just adding the cnames as the string would be all good?

         

        Thanks again , Really appreciate it

         

  • 0691T000009hprnQAA.png ,

     

     

    Thank! I tried your recommendation but I'm having issues on making it work.

     

    • Simon_Blakely's avatar
      Simon_Blakely
      Icon for Employee rankEmployee
      when HTTP_REQUEST {
      # jt_cname_dg is a datagroup of type string containing matching cnames
         log local0. "hostname [HTTP::host]"
       
         if { [class match [string tolower [HTTP::host]] equals jt_cname_dg]} {
           log local0. "matched datagroup"
           pool jt_pool
         } else {
           log local0. "no datagroup match"
         }     
      }

      I missed the class match

  • Thanks  ,

     

    Actually I was thinking if its possible if we can redirect anything that is not equal to mydomain.com into a specific pool instead? is that something possible