Forum Discussion
Can we have iRule for non-http requests?
Can we have iRule for non-http requests? Lets say, my VIP listens on port 9080
Yes. you can configure iRule. What is your requirement.
- T_Srinivas
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?
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
Cirrus
Thank you Samir. Option 1 seems to be better one for me. Can we have pool instead of VIP.
- when HTTP_REQUEST {
- if { [HTTP::uri] starts_with "/BravaServer" } {
- pool newpool_9080
- }
- }
This pool newpool_9080 is from a different VIP on the same F5.
Yes. You can try it.
- T_Srinivas
Cirrus
I will try and let you know Samir. Thank you very much.
- T_Srinivas
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
expecting help from the community
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com