Forum Discussion

Thiyagu_343098's avatar
Thiyagu_343098
Icon for Nimbostratus rankNimbostratus
May 16, 2018

URI redirection using Switch

Hello All, I'm looking for a script to do redirection of request to specific pool which matches specific URI.

 

Could any one provide a script which help to do URI redirection to a pool using switch?

 

Thanks a lot in adavance of your help.

 

Regards, Thiyagu

 

  • There are many many Irule available in devcentral. But I will suggest you to use f5 policy to match URI n redirect traffic to pool... Create a new policy with properties:

    Policy requires http Policy controls forwarding For each policy rule, define:

    condition : http-uri parh starts_with /bugid action : forward pool pool_x Create a default rule without conditon assigning the default pool..

    Example iRule(use of data group)

     when HTTP_REQUEST {
    if { [class match [string tolower [HTTP::path]] starts_with "uri_DataGroup" }{
        pool pool_x
    }
    else {
        pool defaultPool
        }
    }
    
    • Samir_Jha_52506's avatar
      Samir_Jha_52506
      Icon for Noctilucent rankNoctilucent

      Find the iRule with Switch...

      when HTTP_REQUEST {
          set uri [string tolower [HTTP::path]]
          switch -glob $uri {
      
        "/book/" {
           pool pool_A
        }
        "/manage/" {
           pool pool_B
        }
        "/checkin/" {
           pool pool_C
            }
        }
      }