Forum Discussion

Keith_Richards_'s avatar
Keith_Richards_
Icon for Nimbostratus rankNimbostratus
Jun 22, 2008

switch for redirects

I am trying to redirect some URIs, and direct others to a pool. The following rule will not issue an HTTP redirect (TMOS 9.4.4)

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::uri] ] {

 

"/app1*" { HTTP::redirect "https://www.company.com/PRODapp1" }

 

"/app2*" { HTTP::redirect "https://www.company.com/COMPANY/" }

 

"/app3*" { pool pool_app3 }

 

"/COMPANY*" { pool pool_COMPANY }

 

"/*" { pool pool_COMPANY }

 

}

 

 

Any thoughts on what I'm getting wrong?

 

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hey Keith,

    Can you add logging to the rule? Does the matching work for a single HTTP request on a TCP connection? Also, make sure to set all the switch case URI's to lower case as you're setting the URI to lower case (like /company).

     
     when HTTP_REQUEST { 
        switch -glob [string tolower [HTTP::uri] ] { 
           "/app1*" { 
              log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri] matched /app1" 
              HTTP::redirect "https://www.company.com/PRODapp1" 
           } 
           "/app2*" { 
              log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri] matched /app2" 
              HTTP::redirect "https://www.company.com/COMPANY/" 
           } 
           "/app3*" { 
              log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri] matched /app3" 
              pool pool_app3 
           } 
           "/company*" { 
              log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri] matched /company" 
              pool pool_COMPANY 
           } 
           default { 
              log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri] matched default" 
              pool pool_COMPANY 
           } 
        } 
     } 
     

    Aaron