Forum Discussion

8 Replies

  • Yes. you can configure iRule. What is your requirement.

  • Lets say following is the URL

    https://www.facebook.com/BravaServer/searcg.searcgtest/872689

     

    If [HTTP:uri] contains "BravaServer"

     

    Then I want this to redirect to the VIP which is listening on port 9080.

     

    Can you help me with iRule script for this?

     

     

     

     

  • If URI is place is fix then try to use starts_with function to achieve goal.

    Customize below irule based on your requirements. This just an Example

    Option 1:

    when HTTP_REQUEST { 
        if { [HTTP::uri] starts_with "/BravaServer" } {
            HTTP::redirect "http://www.abc.com:9082/"
        } 
    }

    Option 2:

    when HTTP_REQUEST { 
      if { [HTTP::uri] contains "BravaServer" } {
        HTTP::redirect "http://www.abc.com:9082/"
      } 
    }

    Thanks

    • T_Srinivas's avatar
      T_Srinivas
      Icon for Cirrus rankCirrus

      Thank you Samir. Option 1 seems to be better one for me. Can we have pool instead of VIP.

       

      1. when HTTP_REQUEST {
      2. if { [HTTP::uri] starts_with "/BravaServer" } {
      3. pool newpool_9080
      4. }
      5. }

       

       

       

      This pool newpool_9080 is from a different VIP on the same F5.

  •  

    Hi Samir/all,

     

    From the below mentioned iRules, Option 1 works fine, but when I try with Option 2, it doesn't work(Means, I am able to create and save the iRule, but when I associate with VIP and checking with end users to test it. Its not working as per iRule expectation. I was expecting atleast first "if" condition should work). Anything wrong with Option 2 script? When we get next Change window, I am also planning to check Option 3 irule. Is that Option3 iRule fine?

     

     

    Option 1:

    when HTTP_REQUEST { 

      if { [HTTP::uri] equals "/" } { 

    HTTP::redirect "https://dctm.corp.abccompany.com/D2"

      } 

    }

     

     

     

    Option 2

    when HTTP_REQUEST { 

       if { [HTTP::uri] equals "/" } { 

    HTTP::redirect "https://dctm.corp.abccompany.com/D2"

      } 

    elseif { [HTTP::uri] starts_with "/BravaServer" } {

    HTTP::redirect "http://dctmsecondary.corp.abccompany.com:9080/BravaServer/search/searchtext/52d768ebf0179a2762d444277a17ff015ae19482ad8b24bc7712dd44dbaa627e?request.preventCache=1591756362805 status: 0"

    }

    else {

    drop

    }

    }

     

     

    Option 3

    when HTTP_REQUEST { 

       if { [HTTP::uri] starts_with "/BravaServer" } { 

    HTTP::redirect "http://dctmsecondary.corp.abccompany.com:9080/BravaServer/search/searchtext/52d768ebf0179a2762d444277a17ff015ae19482ad8b24bc7712dd44dbaa627e?request.preventCache=1591756362805"

      } 

    }

    else {

    HTTP::redirect "https://dctm.corp.abccompany.com/D2"

    }

    }