For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Snl's avatar
Snl
Icon for Cirrostratus rankCirrostratus
Jun 27, 2016

Irule help need to remove the port before sending uri to server

Folks Need help here

i am trying to remove port information before sending the uri with match keyword to server which listen on only port 80

example VIP 1.1.1.1:9443 NODE- 10.10.10.10:80

Client to VIP - request uri - https://abc.xyz.com:9443/loadWsSingleProvider/services/MaWSPo?wsdl

catch here is we need to send entire URI to the server by removing the port only

i am not able to get the proper irule for this , can somebody help me on this

below is the irule i tried

 


when HTTP_REQUEST { 
   if { [string tolower [HTTP::uri]] contains "loadWsSingleProvider" } { 
      HTTP::header replace Host "[string map {":9443" ""} [HTTP::header Host]]" 
      pool POOL123 
      if { [active_members POOL123] equals 0 } { 
         HTTP::redirect "https://abc.xyz.com" 
         log local0. "POOL123 is down"
      } 
   } 
}

 

2 Replies

  • Derek_Qiao_1388's avatar
    Derek_Qiao_1388
    Historic F5 Account

    You have used "string tolower ..." but later you use contains "loadWsSingleProvider", so this 'if' statement cannot match. Should be either remove string tolower or change loadWsSingleProvider to loadwssingleprovider.

     

  • Hi,

    You have a command easier than :

     

    HTTP::header replace Host "[string map {":9443" ""} [HTTP::header Host]]

     

    You can use the command below instead :

     

    HTTP::header replace Host [getfield [HTTP::header Host] ":" 1]

     

    Below the whole code sample with some proposals :

     

    when HTTP_REQUEST { 
        if { ([HTTP::uri] contains "loadWsSingleProvider") } { 
            if { !([active_members POOL123]) } { 
                HTTP::respond 302 Location "https://abc.xyz.com" 
                log local0. "POOL123 is down"
            } else {
                HTTP::header replace Host [getfield [HTTP::header Host] ":" 1] 
                pool POOL123 
            }
        } 
    }