Forum Discussion

Glenn_32974's avatar
Glenn_32974
Icon for Nimbostratus rankNimbostratus
Jan 05, 2015

Help in improve URI based irule

Hello Folks

 

I have the following situation...

 

Im deploying LTM in front of SharePoint farm that will host our new website

 

We are moving content from our old web servers to our new Sharepoint servers... In the process i Need

 

everytime anyone access http://mycoolapp.com/ I need to have this request being sent to pool_A ( since Sharepoint will send a 301 for redirect to http://mycoolapp.com/Paginas/default.aspx I need this request also being sent to pool_A... Any other URI /styles, /library, etc should be sent to Pool_B

 

I created the irule below which does what I need in a very inefficient way

 

Can anyone provide a better more efficient example please!

 

Thanks a lot!

 

when HTTP_REQUEST { if { [HTTP::uri] == "/" } { pool pool_A log local0. "Home page hit /" } elseif { [HTTP::uri] == "/Paginas/default.aspx" } { pool pool_A log local0. "redirected to Paginas/default.asp" } elseif { [HTTP::uri] contains "/Style%20Library" } { pool pool_B log local0. "searching STYLES in server 26" } elseif { [HTTP::uri] contains "/_layouts" } { pool pool_B log local0. "searching LAYOUTS in server 26" } else { pool pool_B log local0. "SERVER 29" } }

 

3 Replies

  • I'd recommend simplifying your iRule to something like the following if you were still wanting to use it. Otherwise, I'd suggest using a Local Traffic Policy to check the uri (and if need be, the hostname), and assign the pool that way. Using the policy, you could just have a default pool,

    pool_B
    assigned to the Virtual Server, and then in the policy change the pool for
    /
    and
    /Paginas/default.aspx
    . Because the policy method is built-in, it's more efficient than using an iRule.

    when HTTP_REQUEST { 
        switch -glob -- [string tolower [HTTP::path]] {
            "/" -
            "/paginas/default.aspx" {
                log local0. "Pool A: '[HTTP::path]'"
                pool  pool_A
            }
            default {
                log local0. "Pool B: '[HTTP::uri]'"
                pool pool_B
            }
        }
    }
    
  • Thanks a lot Miachel! Your recommended irule worked perfectly! I'll try to test the policies to see the results but I think the irule will do!