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

kirankiran Member
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
}

Comments

  • troyptroyp Member
    edited November 2015
    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.
  • kirankiran Member
    edited November 2015
    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
  • kirankiran Member
    edited November 2015
    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
    }
    }
Sign In or Register to comment.