Forum Discussion
an iRules to redirect http traffic
Dear all external user can access http://123.10.1.1:9090/abc , we need to load balance between two internal server 10.173.20.13:8080/abc and 10.173.20.14:8080/abc and there is another service http://123.10.1.1:9090/cde , we need to load balance between 10.173.20.15:7070/cde and 10.173.20.16:7070/ced can iRule do this and how to do?? Thanks!
7 Replies
- fgf_165674
Nimbostratus
Hi Frank,
yes, you can do it with an iRule.
when HTTP_REQUEST {
if { [HTTP::uri] contains "abc" } {
pool pool1} elseif { [HTTP::uri] contains "cde" } {
pool pool2}
}
- Samir_Jha_52506
Noctilucent
Done some modification in above irule. Rest every thing is correct.
when HTTP_REQUEST { if {[string tolower[HTTP::uri]] starts_with "/abc"} { pool pool1 } elseif {[string tolower[HTTP::uri]] starts_with "/def"} { pool pool2 } }- Frank_Cai_30145
Nimbostratus
thanks!
- jurgenvdmark_14
Nimbostratus
Instead of using iRules, you can also use a ltm policy, which makes it more visible:
Name: select_pool Requires: http Controls: forwarding
Rule: forward_pool1 Condition: http-uri starts_with /abc Action: forward pool pool1 Rule: forward_pool2 Condition: http-uri starts_with /def Action: forward pool pool2
It may require some more configuring then using an iRule but instead of using TCL code, you get an clear overview what the policy does.
- Frank_Cai_30145
Nimbostratus
thanks! I will try it.
- Frank_Cai_30145
Nimbostratus
thanks, there is another question. how do i setting local traffic VS's default pool? or don't need the default pool?
- Vijay_E
Cirrus
Assuming that you have configured default pool within the VS configuration, you can use an iRule like this modified from @jhass' iRule:
when CLIENT_ACCEPTED { set DEFAULT_POOL [LB::server pool] } when HTTP_REQUEST { if {[string tolower[HTTP::uri]] starts_with "/abc"} { pool pool1 } elseif {[string tolower[HTTP::uri]] starts_with "/def"} { pool pool2 } else { pool DEFAULT_POOL } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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