Forum Discussion

Gregt_33960's avatar
Gregt_33960
Icon for Nimbostratus rankNimbostratus
May 13, 2008

Masking or Redirect?

Hello,

 

 

I am hoping some one can help me. I multiple application environments running (test, train, dev, etc..) on a group of web servers. To get to each environment, the client browser needs to use the full URL, listed below.

 

 

http://www.domain.com/test/jsp/common/pgLogin.jsp

 

http://www.domain.com/training/jsp/common/pgLogin.jsp

 

http://www.domain.com/dev/jsp/common/pgLogin.jsp

 

 

I have created the necessary pool definitions on the F5. I have an IRule in place on my F5 that URI filters based on the environment name (test, training, dev) and sends to appropriate pool successfully. However, I am trying to add logic to my IRule that does not require the client to have to use the Fully Qualified URL.

 

 

When a user types: http://www.domain.com/test/ --> we get page not found. How do I modify my Irule so this would work? Not sure if redirect or masking? I do not believe I want redirect, because that forces the client to initiate a new session. Is more forwarding?

 

 

Here is my current IRule syntax:

 

 

when HTTP_REQUEST {

 

log local0. "Current URI: [HTTP::uri]"

 

if {[HTTP::uri] starts_with "/test" }{

 

pool state_test_pool

 

} elseif {[HTTP::uri] starts_with "/dev"}{

 

pool state_dev_pool

 

} elseif {[HTTP::uri] starts_with "/train"}{

 

pool state_train_pool

 

}

 

}

 

 

 

Any insight would be extremely helpful.

 

 

Thanks

 

Greg

 

4 Replies

  • Hi Greg,

    I haven't tested this, but see if this actually works.

     
     when HTTP_REQUEST { 
        log local0. "Current URI: [HTTP::uri]" 
        switch  [HTTP::uri] { 
           "/test" {  
                 HTTP::uri "/test/jsp/common/pgLogin.jsp" 
                 pool state_test_pool         
                      } 
          "/dev" {  
                 HTTP::uri "/dev/jsp/common/pgLogin.jsp" 
                 pool state_dev_pool        
                } 
          "/train" {  
                 HTTP::uri "/train/jsp/common/pgLogin.jsp" 
                 pool state_train_pool        
               } 
          } 
     } 
     

    thanks,

    CB
  • CB,

     

     

    Thank you for the information. Unfortunately the code did not work as the F5 complained about invalid syntax and statements. But I took your logic and applied to my exiting rules and made considerable progress... As it turns out my pgLogin.jsp makes several HTTP requests with that URI variable (dev, test, train) for images and such, which partially broke my web page. I then inserted a nested if statement to indicate that if the initial request ends with the URI variable (test, train, dev) go to the Login page, otherwise keep loading.

     

     

     

     

    when HTTP_REQUEST {

     

    log local0. "Current URI: [HTTP::uri]"

     

    if {[HTTP::uri] starts_with "/test" }{

     

    if {[HTTP::uri] ends_with "/test" }{

     

    HTTP::uri "/test/jsp/common/pgLogin.jsp"

     

    }

     

    pool state_test_pool

     

    } elseif {[HTTP::uri] starts_with "/dev"}{

     

    if {[HTTP::uri] ends_with "/dev" }{

     

    HTTP::uri "/dev/jsp/common/pgLogin.jsp"

     

    }

     

    pool state_dev_pool

     

    } elseif {[HTTP::uri] starts_with "/train"}{

     

    if {[HTTP::uri] ends_with "/train" }{

     

    HTTP::uri "/train/jsp/common/pgLogin.jsp"

     

    }

     

    pool state_train_pool

     

    }

     

    }

     

     

     

     

    I hope this makes sense..if I might ask, is there an easier way to write this? it seems kind of clugy at best

     

     

    thanks again,

     

    Greg

     

  • Hi Greg,

     

    what kind of syntax and statement error did you recieve. I just popped into my F5 Editor and it didn't complain about the sytax.

     

     

    CB

     

  • Hi,

    You should use the iRule editor since the iRule editor is more flexible than through the GUI i.e a space forgotten may create syntax issue.

    For example in the GUI you should add a space between } and { for a if statement

    Try this one:

     
     when HTTP_REQUEST { 
       log local0. "Current URI: [HTTP::uri]" 
       if {[HTTP::uri] starts_with "/test" } { 
           if {[HTTP::uri] ends_with "/test" } { 
              HTTP::uri "/test/jsp/common/pgLogin.jsp" 
           } 
          pool state_test_pool 
       } elseif {[HTTP::uri] starts_with "/dev"} { 
          if {[HTTP::uri] ends_with "/dev" } { 
              HTTP::uri "/dev/jsp/common/pgLogin.jsp" 
          } 
          pool state_dev_pool 
       } elseif {[HTTP::uri] starts_with "/train"} { 
          if {[HTTP::uri] ends_with "/train" } { 
              HTTP::uri "/train/jsp/common/pgLogin.jsp" 
           } 
           pool state_train_pool 
        } 
     }  
     

    If it doesn't work i would strongly advise to use the iRule editor, if not possible then here a way to find your syntax error message:

    Remove all your iRule in a notepad for example and insert it back piece by piece. This way as soon as you have the syntax error message you'll find the culprit area. Works fine usually, not the most convenient way but the sytanx error message can tell you the wrong line sometimes!

    HTH