iRule - A lot of urls with single VIP
Hi gents
I need to create a iRule for multiple urls with single VIP. Could you please let me get your knowledge?
The following is the URL structure.
*.(application)-(environment).test.com
The examples of URLs requested by users are;
test10.test-t10.test.com
test20.test_api-t10.test.com
testbranch11.lab-t10.test.com
testbranch22.lab_api-t10.test.com
The first part of URL like "test10", "test20" can change anytime.
We have mutiple servers from T10 to T20. More servers(T21, T22...) will be added later
According to the server number, the urls will be like the followings.
[T10]
*.test-t10.test.com
*.test_api-t10.test.com
*.lab-t10.test.com
*.lab_api-t10.test.com
[T11]
*.test-t11.test.com
*.test_api-t11.test.com
*.lab-t11.test.com
*.lab_api-t11.test.com
The other servers(T12 to T20) will provide internet service with the same URL patterns above.
After F5 LTM checks HTTP request, LTM will load balance to a proper pool.
[exmaple]
*.test-t10.test.com ==> Go to pool named "PL_test-t10.test.com"
*.test_api-t10.test.com ==> Go to pool named "PL_test_api-T10.test.com"
*.lab-t10.test.com ==> Go to pool named "PL_lab-t10.test.com"
*.lab_api-t10.test.com ==> Go to pool named "PL_lab_api-t10.test.com"
*.test-t11.test.com ==> Go to pool named "PL_test-t11.test.com"
*.test_api-t11.test.com ==> Go to pool named "PL_test_api-T11.test.com"
*.lab-t11.test.com ==> Go to pool named "PL_lab-t11.test.com"
*.lab_api-t11.test.com ==> Go to pool named "PL_lab_api-t11.test.com"
The other servers from T12 to T20 will be the same load balancing patterns.
I have created a rule for this request. Could you please advise me if this irule works correctly? The main idea of the iRUle is that I do not want to update the iRule when any server is added to the load balancing pool.
[iRule]
when HTTP_REQUEST { if {[scan [string tolower [HTTP::host]] "test-t%2d.test.com" boxnumber] == 1 } { pool "PL_test-T${boxnumber}.test.com" unset boxnumber }
elseif {[scan [string tolower [HTTP::host]] "test_api-t%2d.test.com" boxnumber] == 1 } { pool "PL_test_api-T${boxnumber}.test.com" unset boxnumber }
elseif {[scan [string tolower [HTTP::host]] "lab-t%2d.test.com" boxnumber] == 1 } { pool "PL_lab-T${boxnumber}.test.com" unset boxnumber }
elseif {[scan [string tolower [HTTP::host]] "lab_api-t%2d.test.com" boxnumber] == 1 } { pool "PL_lab_api-T${boxnumber}.test.com" unset boxnumber } }