Forum Discussion

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

IRULES to append and Web Server Errors

 

Hello,

 

 

I have found this forum extremely helpful as I learn more about IRules. I have multiple application environments running on pools of webservers. I have to set the F5 to perform URI Filtering, which I have successfully done to a certain point. In addition, because of the way the developers deploy the XML, that when a user types in the URL::URI the first time to login I have to append a string on the end of the request to get to the login page. That to is successful to a point.

 

 

I have two issues that I need resolving and my IRules are not working and not sure how to proceed. Any insight would be wonderful. My IRule is listed below.

 

 

ISSUE 1

 

 

When a user types the URL::URI with a trailing "/" I get standard error "Page not found" from my browser... Example below

 

 

http://test.domain.com/train --> this works fine and get to login Page

 

http://test.domain.com/train/ --> This fails with Page Not found in browser

 

 

I tried adding an "or" statement in my elseif statments but it did not work and actually broke the other pages.

 

 

ISSUE 2

 

 

I have assigned a default pool (user_pool) to the Virtual Server, but I am trying to find the logic similar to the other environments, where a user types:

 

 

http://test.domain.com

 

 

and the F5 appends and the becomes

 

 

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

 

 

I am not seeing how to do that.

 

 

Any help would be grateful

 

Thanks

 

Greg

 

 

 

************* BEGIN IRULE **********************

 

 

URI Load Balancing

 

Desired URI to pool mapping

 

http://test.domain.com --> user_pool

 

http://test.domain.com/train --> train_pool

 

http://test.domain.com/pilot --> pilot_pool

 

http://test.domain.com/whatif --> whatif_pool

 

http://test.domain.com/sandbox --> sandbox_pool

 

 

 

when HTTP_REQUEST {

 

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

 

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

 

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

 

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

 

}

 

pool sandbox_pool

 

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

 

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

 

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

 

}

 

pool pilot_pool

 

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

 

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

 

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

 

}

 

pool whatif_pool

 

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

 

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

 

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

 

}

 

pool train_pool

 

}

 

}

 

 

************** END IRULE ******************

6 Replies

  • Hi, here is your test:

      
      elseif {[HTTP::uri] starts_with "/train"}{  
          if {[HTTP::uri] ends_with "/train" }{  
          HTTP::uri "/train/jsp/common/pgLogin.jsp"  
      }   
      

    you say it MUST ends with /train, so when it ends with /train/ it won't work

    you need to add a or statement like this:

      
      {[HTTP::uri] starts_with "/train"}{  
      if {([HTTP::uri] ends_with "/train") or ([HTTP::uri] ends_with "/train/") }{  
      HTTP::uri "/train/jsp/common/pgLogin.jsp"  
      }   
      

    But couldn't you do that instead:

      
      elseif {([HTTP::uri] equals "/train") or ([HTTP::uri] equals "/train/")}{  
          HTTP::uri "/train/jsp/common/pgLogin.jsp"  
      }   
      

  • Hello,

     

     

    to whomever who wrote that reply, your logic did seem to correct the first issue. I tried something like that but perhaps I had a typo or something.

     

     

    I will now focus on issue 2.. but thank you..

     

     

    Greg
  • Hi,

     

     

    You're welcome

     

     

    Could you explain your issue number 2, i haven't really understand what you would like to achieve
  •  

    Hello,

     

     

    I will certainly try to explain, but I will apologize now for the confusion. Please bear with me as I not be explaining it very well.

     

     

    Our application is terse and not very flexible unfortunately. To get to our application log in page the URL must contain the "/jsp/common/PGLogin.jsp" suffix. But we do not want our user community to have to know all that. Hence the logic you saw from the earlier problem. We have multiple environments (train, user, whatif, pilot) and we use a variable definition on each application server instance (the URI filters by that variable definition) to manage them, and IRULE logic is working for all of them except one. When a user types:

     

     

    http://test.domain.com/train -- the IRULE does the right thing and appends "/train/jsp/common/PGloing.jsp" and sends user to the login page no problem.

     

     

    this works for any URL that will have URI filter on it..

     

     

    We have an application environment mapped to the default pool that is defined to the virtual server...

     

     

    so when the user types in http://test.domain.com I acutally need to create IRULE Logic to append "/user/jsp/common/PGlogin.jsp"

     

     

    I am confused because there is no filtering on the root URL.

     

     

    Here is a sample of what I am attempting. We already know that IRULE logic works for "/train" because it filters on the "/train"... but for the URL mapped to the user pool need to set up logic for that.

     

     

    URI Load Balancing

     

    Desired URI to pool mapping

     

    http://test.domain.com --> user_pool

     

    http://test.domain.com/train --> train_pool

     

     

    Sorry but is that making any sense?

     

     

    thanks

     

    greg

     

  • You could also use a switch statement (Click here) to specify the URI and pool based on the requested URI. Note that if the user types http://test.domain.com into the address bar, the browser will append a forward slash, so the URL will be http://test.domain.com/ and the URI will be /.

      
      URI Load Balancing  
       Desired URI to pool mapping  
       http://test.domain.com --> user_pool  
       http://test.domain.com/train --> train_pool  
       http://test.domain.com/pilot --> pilot_pool  
       http://test.domain.com/whatif --> whatif_pool  
       http://test.domain.com/sandbox --> sandbox_pool  
        
        
      when HTTP_REQUEST {  
        
         log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::uri]"  
        
          Update the URI per the mapping above  
         switch [HTTP::uri] {  
            "/" {  
                Request was to root object  
               log local0. "[IP::client_addr]:[TCP::client_port]: using user_pool"  
               HTTP::uri "/user/jsp/common/PGlogin.jsp"  
               pool user_pool  
            }  
            "/sandbox" -  
            "/sandbox/" {  
               log local0. "[IP::client_addr]:[TCP::client_port]: using sandbox_pool"  
               HTTP::uri "/sandbox/jsp/common/pgLogin.jsp"  
               pool sandbox_pool  
            }  
            "/train" -  
            "/train/" {  
               log local0. "[IP::client_addr]:[TCP::client_port]: using train_pool"  
               HTTP::uri "/train/jsp/common/pgLogin.jsp"  
               pool train_pool  
            }  
            "/pilot" -  
            "/pilot/" {  
               log local0. "[IP::client_addr]:[TCP::client_port]: using pilot_pool"  
               HTTP::uri "/pilot/jsp/common/pgLogin.jsp"  
               pool pilot_pool  
            }  
            "/whatif" -  
            "/whatif/" {  
               log local0. "[IP::client_addr]:[TCP::client_port]: using whatif_pool"  
               HTTP::uri "/whatif/jsp/common/pgLogin.jsp"  
               pool whatif_pool  
            } 
            default { 
                Take some default action? 
            } 
         }  
      }  
      

    Aaron
  • Aaron,

     

     

    I will test this swithc loop logic out but I am not sure I understand it... The issue is differentiating the logic of login page from other page requests. Once the user gets to the login page and authenticates, all other page requests will have that "Variable" in the http reuqest.

     

     

    So for example, I need th F5 behavoir to be as such:

     

     

    When F5 recieves URL http://test.domain.com then

     

    Append "user/jsp/common/PGlogin.jsp" (

     

    send request to user_pool

     

    else if http://test.domain.com/user/webage

     

    send request directly to user_pool

     

    end

     

     

    that is why I have the logic of the nested if, I just need to get to the login page the first time. For all the other environments which have a variable in the string (i.e http://test.domian.com/train) i can filter and send to login page no problem. It is only this one request (http://test.domain.com/)

     

     

    Not sure if I am explaining this correctly so I will apologize.

     

     

     

    thanks

     

    Greg