Forum Discussion
iRule vs. Local Traffic Policy vs. Rewrite Profile
Rewrite URI and send to specific pool/node.
I have a pool with 6 members which is applied to a virtual server. Our support team would like to have the ability to test against each of the 6 members individual to determine the performance of each member.
VS: app.example.com_443_vs
Pool: app.example.com_443_pool
Nodes: node[x].company.com
Host: https://app.example.com
URI: /myApp
I have decided to publish internally https://app.example.com/n[x]/myApp where x is each of the six members. In the past, I would have written an iRule to rewrite /n[x]/myapp to /myApp and select the pool/node based on /n[x], but now I have Local Traffic Policies and Rewrite Profiles at my disposal.
My question is should I perform the rewrite and pool/node selection in an iRule or is it more efficient to utilize a local traffic policy to perform those functions?
3 Replies
- Vijay_E
Cirrus
It is your choice. I prefer iRules for the flexibility. If you have already done similar such iRules, I would recommend sticking with iRules.
- Eric_Frankenfie
Nimbostratus
This is the iRule I created. Do you recommend using IF or CASE statements, or does it not matter?
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/n1" } { HTTP::path "/myApp" pool n1-app.example.com_443_pool } elseif { [HTTP::uri] starts_with "/n2" } { HTTP::path "/myApp" pool n2-app.example.com_443_pool } elseif { [HTTP::uri] starts_with "/n3" } { HTTP::path "/myApp" pool n3-app.example.com_443_pool } elseif { [HTTP::uri] starts_with "/n4" } { HTTP::path "/myApp" pool n4-app.example.com_443_pool } elseif { [HTTP::uri] starts_with "/n5" } { HTTP::path "/myApp" pool n5-app.example.com_443_pool } elseif { [HTTP::uri] starts_with "/n6" } { HTTP::path "/myApp" pool n6-app.example.com_443_pool } else { pool app.example.com_443_pool } } - VernonWells
Employee
You also asked about
vs.if
. For a multi-case conditional like you have above, you should definitely useswitch
. In this case, it's simply because it will only evaluateswitch
once, rather than for each branch. In the worst case for your rule, it will evaluate 6 times.HTTP::uri
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