Forum Discussion

Simon_83666's avatar
Simon_83666
Icon for Nimbostratus rankNimbostratus
Dec 17, 2008

firefox host name with port number when 303

Hi,

 

 

I've written the following to direct traffic depending on the host name. This seem to work fine except for when the http response was a 303 and the browser is Firefox in which case the host name in the subsequent request had the piort number added at the back, e.g. 123.com:80 . Has anyone had this problem before ?

 

 

 

when HTTP_REQUEST {

 

set http_host [HTTP::host]

 

switch -glob $http_host {

 

123.com { pool x member node_1 80 }

 

456.com { pool y member node_2 80 }

 

default { HTTP::respond 200 content "ErrorError detected (F5) " }

 

}

 

}

 

 

 

Simon

2 Replies

  • If the application is including the port in the Location header in redirects, you can parse it out in your switch statement using getfield (Click here). Also, you can set the host values to lower case as the Host header isn't case sensitive. Just make sure to add the switch cases in lower case as well. Finally, you can remove the -glob field from the switch as you're not using any wildcards.

     
     when HTTP_REQUEST { 
        switch [string tolower [getfield [HTTP::host] ":" 1]] { 
           "123.com" { pool x member node_1 80 } 
           "456.com" { pool y member node_2 80 } 
           default { 
              HTTP::respond 200 content { 
                 ErrorError detected (F5) " 
              } 
           } 
        } 
     }  
     

    Aaron
  • Hi ,

     

     

    Thanks for the tips, I found the following would also work by adding the * character to the pattern. Would this be a better approach or potential risk for later ?

     

     

     

    when HTTP_REQUEST {

     

    set http_host [HTTP::host]

     

    switch -glob $http_host {

     

    123.com* { pool x member node_1 80 }

     

    456.com* { pool y member node_2 80 }

     

    default { HTTP::respond 200 content "ErrorError detected (F5) " }

     

    }

     

    }