aFleX to send traffic to a multiple pool based on the hostname and redirect to U

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
 \}

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.

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

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”

\}
\}