Forum Discussion

AlfaSpider_3544's avatar
AlfaSpider_3544
Icon for Nimbostratus rankNimbostratus
May 04, 2012

irule for virtual server to redirect to different pool

Well.....This doesn't work. Any help would be much appreatiated.

 

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains "mywebsite.com/util" } {

 

pool my-util-pool

 

} }

 

}

 

 

 

 

  • Hi,

    If I help do I get a discount on my utilities? 🙂

    Can you try this example which checks the combined host header and path values set to lower case to select the pool? The non-matching requests will use the virtual server's default pool.

    
    when CLIENT_ACCEPTED {
     Save the name of the VS default pool
    set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
    
    switch -glob [string tolower [HTTP::host][HTTP::path]] {
    "*mywebsite.com/util*" {
    "*seattle.gov/util*" } {
    pool spu-util-pool
    }
    default {
    pool $default_pool
    }
    }
    }
    

    Aaron
  • Getting error when trying to update.

     

     

    01070151:3: Rule [spu-util-pool-redirect] error: line 2: [undefined procedure: LB::dmz-lgxdev-pool-http] [LB::dmz-lgxdev-pool-http] line 9: [undefined procedure: default] [default { pool dmz-lgxdev-pool-http }] line 13: [command is not valid in the current scope] [}]

     

     

    This is what I entered

     

     

     

    when CLIENT_ACCEPTED {

     

    set default_pool [LB::dmz-lgxdev-pool-http]

     

    }

     

    when HTTP_REQUEST {

     

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

     

    "*seattle.gov/util*" } {

     

    pool spu-util-pool

     

    }

     

    default {

     

    pool dmz-lgxdev-pool-http

     

    }

     

    }

     

    }
  • [LB::server pool] will return the default pool on the virtual server, so you don't need to update the name or hardcode the pool name in the iRule. Just set spu-util-pool to the name of the pool you want to use for the matching requests.

     

     

    Aaron
  • I'm sorry for so many questions....I'm an irule dummy.

     

     

    Does this look right?

     

     

    when HTTP_REQUEST {

     

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

     

    "*seattle.gov/util*" } {

     

    pool spu-util-pool

     

    }

     

     

    }
  • No worries. Try exactly this:

    when CLIENT_ACCEPTED {
         Save the name of the VS default pool
        set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
    
        switch -glob "[string tolower [HTTP::host][HTTP::path]]" {
            "*seattle.gov/util*" {
                pool spu-util-pool
            }
            default {
                pool $default_pool
            }
        }
    }
    

    Aaron
  • I am so close..................I only get one error when I try to update.

     

     

    01070151:3: Rule [spu-util-pool-redirect] error: line 11: [undefined procedure: default_pool] [default_pool ]

     

     

    I have tried many [ and { but nothing seems to be good enough.
  • Sorry, I had a typo in the iRule above. I edited the post to fix it.

     

     

    Aaron