Forum Discussion
Allen_Yu_168758
Nimbostratus
May 27, 2016Redirecting iRule by URL depth
Hi,
There is a request from our biz users that redirecting packets according URL depth, just wondering if it can be achieved by iRule.
Much appreciate if anyone's feedback.
Example:
the r...
Yann_Desmarest
Cirrus
May 27, 2016Hi,
try this one instead, just tested and found I had an issue with the previous one :
when HTTP_REQUEST {
set lb_depth 0
set lb_len 0
set timeout 3600
set path [string tolower [HTTP::path]]
set depth [URI::path $path depth]
define the depth of the path for hash calculation
if { $depth < $lb_depth } {
set depth_path [URI::path $path 1 $lb_depth]
} else {
set depth_path [URI::path $path 1 $depth]
}
set len [string length $depth_path]
define the chars length to be processed for hash calculation
if { $lb_len > 0 and $lb_len < $len } {
binary scan [sha1 [string range $depth_path 0 $lb_len-1]] w1 key
} else {
binary scan [sha1 $depth_path] w1 key
}
persist uie $key $timeout
}
- tpts6May 31, 2016
Nimbostratus
Hi Yann Many thanks for your reply. And I really sorry ask more as below : May I have one more question ? If the condition also consideration for pool selection by match domain. Should we merge into same irule or split two ? For example : When access to https://www.abc123.com/111-xxx/222-yy/333-z/nnnnn if match www.abc.123.com then select pool_123 "AND" match depth eq 3 (/111-xxx/222-yy/333-z in this case) then redirect this request to the same node(backend server) everytime. When access to https://www.xyz456.com/444/555/666/mmmmm if match www.xyz456.com then select pool_456 "AND" match depth eq 3 (/444/555/6666 in this case) then redirect this request to the same node(backend server) everytime. elseif match www.qaz789.com then select pool_789 elseif macth www.wsx000.com then select pool_000 ***Note : only match www.abc123.com and www.xyz456.com apply "depth eq 3" rule.*** - Yann_DesmarestMay 31, 2016
Cirrus
Looks like pool and depth selection are linked by hostname, so yes would be good to merge into one irule. This avoid you to set the same "if/else" conditions on several irules - tpts6May 31, 2016
Nimbostratus
Thanks for your advice !! ^^ I will keeping study syntax how to merge into one irule or try another workaround. Due to developer/vendor have no idea on F5-irule, but they are not prefer to implement on backend servers.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects