Forum Discussion

Alex_f5's avatar
Alex_f5
Icon for Altostratus rankAltostratus
Oct 05, 2017

Irule to redirect to specific pool based on URI + delete the URI working intermittently

Hi, abcd_irule is an irule that is working but sometimes fails,

This is the irule content:

when HTTP_REQUEST {
if { [HTTP::uri] contains "/client/v1*" } {
pool abcd_client_pool
if { [string tolower [HTTP::uri]] contains "/client*" } {
HTTP::respond 301 noserver Location "https://[HTTP::host]"
}
} elseif { [HTTP::uri] contains"/partner/v1*" } {
pool abcd_partner_pool
if { [string tolower [HTTP::uri]] contains "/partner*" } {
HTTP::respond 301 noserver Location "https://[HTTP::host]"
}
}
}

Basically what I need is that when somebody goes to https://abcd.company.com/client/v1* the request falls in pool named abcd_client_pool and the request reaches the root directory of the pool member. If user goes to https://abcd.company.com/partner/v1* the request must go to pool abcd_partner_pool and same, the request should go to the root directory of the back end server. This usually works, and if the user tries in an incognito chrome window it works any time, however, if user tries in a regular chrome window the user get connection reset.

I have logged the results when works and when fails:

* WORKING
Oct  4 20:58:40 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /client/v1
Oct  4 20:58:40 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /
Oct  4 20:58:41 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /tomcat.css
Oct  4 20:58:41 slot1/bigip1 info tmm2[21479]: Rule /Common/abcd_irule : URI is /tomcat.png
Oct  4 20:58:42 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /bg-middle.png
Oct  4 20:58:42 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /bg-upper.png
Oct  4 20:58:42 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /bg-button.png
Oct  4 20:58:42 slot1/bigip1 info tmm2[21479]: Rule /Common/abcd_irule : URI is /asf-logo-wide.svg
Oct  4 20:58:42 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /bg-nav.png
Oct  4 20:58:42 slot1/bigip1 info tmm1[21479]: Rule /Common/abcd_irule : URI is /bg-upper.png

* NOT WORKING
Oct  4 20:58:12 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /
Oct  4 20:58:12 slot1/bigip1 info tmm1[21479]: Rule /Common/abcd_irule : URI is /
Oct  4 20:58:13 slot1/bigip1 info tmm[21479]: Rule /Common/abcd_irule : URI is /

Any help is appreciated. thanks. Alex.

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    you can try something simple, like below. However, i'm not sure if i understood "/partner" & "/client". Correct me if I misunderstood.

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] starts_with "/client/v1/" } {

     

    pool abcd_client_pool

     

    } elseif { [HTTP::uri] starts_with "/partner/v1/" } {

     

    pool abcd_partner_pool

     

    }

     

    else {

     

    HTTP::respond 301 noserver Location "https://[HTTP::host]"

     

    }

     

    }