cancel
Showing results for 
Search instead for 
Did you mean: 

Can we have iRule for non-http requests?

T_Srinivas
Cirrus
Cirrus

Can we have iRule for non-http requests? Lets say, my VIP listens on port 9080

8 REPLIES 8

Samir
Nacreous
Nacreous

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

T_Srinivas
Cirrus
Cirrus

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?

 

 

 

 

Samir
Nacreous
Nacreous

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

 

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.

Samir
Nacreous
Nacreous

Yes. You can try it.​

T_Srinivas
Cirrus
Cirrus

I will try and let you know Samir. Thank you very much.

T_Srinivas
Cirrus
Cirrus

 

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"

}

}

T_Srinivas
Cirrus
Cirrus

expecting help from the community