Forum Discussion

newf5learner_13's avatar
newf5learner_13
Icon for Nimbostratus rankNimbostratus
Mar 15, 2017

irule for URI based redirection and to the pool..

Hi,

I'm looking for a short irule that helps in two ways.

  1. URI redirection
  2. Host based pool selection

I currently have two irules, I'm looking for one combined irule that serves the purpose.

Host to pool selection:

when HTTP_REQUEST {
  switch -glob [ string tolower [HTTP::host]] {
  "eng.page3.com" { pool page3_https_pool }
  "eng.devpage3.pega.com" { pool devpage3_https_pool }
  default { HTTP::respond 404 noserver }
  }

URI based redirection:

when HTTP_REQUEST {
    if {[HTTP::uri] starts_with "/ClientService/BI-Integration/"} { 
        switch -glob [string tolower [HTTP::host]] {
            "eng.page3.com" {HTTP::redirect "/clientapp[HTTP::uri]"}
        }
    }
}

Can someone help me with a irule that gives me the combined features of both. I don't like to use two separate irules on the same VIP, so checking if there is any better option.

  • Hi,

     

    Just rearranging the code a bit may answer the question:

     

    when HTTP_REQUEST {
        switch -glob [ string tolower [HTTP::host]] {
            "eng.page3.com" { 
                    if {[HTTP::uri] starts_with "/ClientService/BI-Integration/"} {
                        HTTP::redirect "/clientapp[HTTP::uri]"
                    }
                    else {pool page3_https_pool }
                }
            "eng.devpage3.pega.com" { pool devpage3_https_pool }
            default { HTTP::respond 404 noserver }
        }
    }