kiran
November 5, 2015, 12:48pm
1
How to send the traffic to multiple pools based on hostname and redirect URI to path
I am trying below script but it is not working. Can some one tell me working script.
when HTTP\_REQUEST \{
if \{[HTTP::host] matches "abc.in" and not ([HTTP::uri] starts\_with "/abc-api") \} \{
HTTP::redirect “http://abc.in/abc-api/login ”
pool abc_in
} elseif {[HTTP::host] matches “www.abc.in” and not ([HTTP::uri] starts_with “/wwwabc-api”) } {
HTTP::redirect “http://www.abc.in/wwwabc-api/login ”
pool www\_abc\_in
\} elseif \{[HTTP::host] matches "admin.abc.in" and not ([HTTP::uri] starts\_with "/admin") \} \{
HTTP::redirect “http://admin.abc.in/admin/sign_in.php ”
pool admin\_abc\_in
\}
troyp
November 5, 2015, 1:00pm
2
You may want to post your config for your VIP(s) and Pools that pertain to this aflex… using both redirects and pools in the same function shouldn’t be necessary.
kiran
November 5, 2015, 2:24pm
3
I did not mentioned any sg pool in VIP, but using aflex i want to select the sg pool by hostname and redirect that hostname to complete URI.
As i mentioned in the aflex script
kiran
November 6, 2015, 9:59am
4
Finally using below method, I am able to achieve what I expect.
when HTTP\_REQUEST \{
set host [HTTP::host]
if \{ $host matches "abc.in" \} \{
pool “abc_in”
\} elseif \{ $host matches "www.abc.in" \} \{
pool "www\_abc\_in"
\} elseif \{ $host matches "admin.abc.in"\} \{
pool "admin\_abc\_in"
\}
\}
when HTTP\_REQUEST \{
if \{[HTTP::host] matches “abc.in” and not ([HTTP::uri] starts\_with “/abc-api”) \} \{
HTTP::redirect “http://abc.in/abc-api/login”
} elseif {[HTTP::host] matches “www.abc.in” and not ([HTTP::uri] starts_with “/wwwabc-api”) } {
HTTP::redirect “http://www.abc.in/wwwabc-api/login”
} elseif {[HTTP::host] matches “admin.abc.in” and not ([HTTP::uri] starts_with “/admin”) } {
HTTP::redirect “http://admin.abc.in/admin/sign_in.php”
\}
\}