Forum Discussion

JimmyJose's avatar
JimmyJose
Icon for Nimbostratus rankNimbostratus
Nov 02, 2018

Pool selection using iRule not working

Hi,

I am having a hard time writing an irule to select from pools based on URIs for the same host.

The irule looks like this.

=================================

when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
  "site1.company.com" {
   switch -glob [string tolower [HTTP::uri]] {
      "/Tabs.aspx" {
        pool site1-pool-port81
        }
      "/" {
        HTTP::redirect "http://[HTTP::host]/Home.aspx";
        pool site1-pool
        } 
        }
        }

  "site2.company.com" {
   switch -glob [HTTP::uri] {
      "/" {
        HTTP::redirect "http://[HTTP::host]/Home.aspx";
        pool site2-pool
      }
      default {pool site2-pool}
      }
      }


    "site3.company.com" {
     switch -glob [HTTP::uri] {
      "/" {
        HTTP::redirect "http://[HTTP::host]/Home.aspx";
        pool site3-pool
      }
        default {pool site3-pool}
    }
  }
  }
  }

=================================

Everything (site1, site2, site3) works fine except for ";. Since the default pool on the VS is "site1-pool", "site1-pool-port81" does not selected. I can see the requests going to the wrong pool via 'tmsh'.

On the other hand, if the default pool on the VS is set to "site1-pool-port81", "; starts working, but then, "/" stops redirecting to the home page. Even trying to access "site1.company.com/Home.aspx" fails.

Any help would be highly appreciated!

-Jimmy =-=-=

1 Reply

  • Try changing this line of the switch statement to lower case:

    "/Tabs.aspx"

    You've done a string tolower on the URI but are then comparing it against a string with an upper case character.