Forum Discussion

mnb_63148's avatar
mnb_63148
Icon for Nimbostratus rankNimbostratus
Jul 14, 2015

iRule sending traffic to wrong pool

I have an iRule where I am trying to send the traffic to a specific pool if the iRule contains a specific URI (/MyExample in this instance). The URI being requested by the application is /MyExample/abc/xyz.do?{%22xyz}. For some reason, the iRule is sending the traffic to the default pool instead of the example_pool, which is where I need it to go. Any help would be greatly appreciated.

when HTTP_REQUEST {

switch -glob [HTTP::uri] {

"/MYExample*" { pool example_pool }

                          }

switch -glob [string tolower [HTTP::path]] {

"/"      { HTTP::respond 301 "Location" "http://[HTTP::host]/abc/" }

    default  { pool abc.com_pool }

}

}

3 Replies

  • You need to also apply OneConnect to your VIP (in the HTTP profile and in the VIP itself).

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] {
            "/myexample*" {
                pool example_pool
            }
            "/" {
                HTTP::respond 301 Location "http://[HTTP::host]/abc/"
            }
            default {
                pool abc.com_pool
            }
        }
    }
    
  • Here's your iRule reformatted for easier viewing:

    when HTTP_REQUEST {
        switch -glob [HTTP::uri] {
            "/MYExample*" { 
                pool example_pool 
            }
        }
        switch -glob [string tolower [HTTP::path]] {
            "/" { 
                HTTP::respond 301 "Location" "http://[HTTP::host]/abc/" 
            }
            default  { 
                pool abc.com_pool 
            }
        }
    }
    

    So a few comments:

    1. HTTP::uri and HTTP::path will return pretty much the same information up to any query string data, and since you're only looking for the beginning of any URI, you could combine these two switches and just use HTTP::uri (or HTTP::path).

    2. You don't need to do a [string tolower ] if you're only evaluation is "/"

    3. You absolutely need OneConnect enabled

  • OneConnect is generally a requirement when doing "content switching" within a single VIP - sending traffic to different pools based on some request criteria. In a nutshell, once the VIP has made a load balancing decision you may experience problems switching to other servers as long as a TCP session is open to one server. The OneConnect profile allows the VIP to process each HTTP request individually.

     

    sol7208: Overview of the OneConnect profile