Forum Discussion

Sabir_Alvi's avatar
Sabir_Alvi
Icon for Altocumulus rankAltocumulus
Feb 13, 2020

Redirect requests to second VIP (VIP to VIP redirection)

We have 2 different VIPs created with different profile configurations. We need to redirect traffic for a particular URI to the Second VIP, while everything else is handled by the First VIP. We have tried below iRules but it hasn't helped, the request is not getting redirected to Second VIP. Any help would be highly appreciated!! We have logging enabled and it only says the request was sent to the pool on First VIP.

when HTTP_REQUEST {
   log local0. "Request to: [HTTP::host] from [IP::client_addr]"
  switch -glob [string tolower [HTTP::host][HTTP::uri]] {
    "something.com/blah/blah/blah.svc*" {
      virtual second_vip_name
    }
  }
}
when HTTP_REQUEST {
   log local0. "Request to: [HTTP::host] from [IP::client_addr]"
  set uri [string tolower [HTTP::uri]]
  if { ( $uri contains "/blah/blah/blah.svc")
     } {
    virtual second_vip_name
  }
}

I referred this as well - https://devcentral.f5.com/s/articles/20-lines-or-less-64-vip-to-vip-redirection-url-separation-and-redirect-rewriting

5 Replies

  • Hi,

     

    I tend to agree with  

     

    Whenever you can, use an LTM policy with Foward To Virtual Server action. I use this quite often to implement "Virtual Servers Brokers".

     

    Yoann

  • Hey,

     

    Try this iRule,

     

    when HTTP_REQUEST {

      if {([string tolower [HTTP::uri]] contains "/xyz") and [string tolower [HTTP::host]] equals "abc"}{

        HTTP::redirect https://xyz;

      }

    }

     

     

    Also you can even try F5 Policy to match URI n redirect traffic.

     

    Hope it helps !

     

    Mayur