Forum Discussion
Gregt_33960
Nimbostratus
May 22, 2008IRULES 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 ******************
- Nicolas_Menant
Employee
Hi, here is your test:elseif {[HTTP::uri] starts_with "/train"}{ if {[HTTP::uri] ends_with "/train" }{ HTTP::uri "/train/jsp/common/pgLogin.jsp" }
{[HTTP::uri] starts_with "/train"}{ if {([HTTP::uri] ends_with "/train") or ([HTTP::uri] ends_with "/train/") }{ HTTP::uri "/train/jsp/common/pgLogin.jsp" }
elseif {([HTTP::uri] equals "/train") or ([HTTP::uri] equals "/train/")}{ HTTP::uri "/train/jsp/common/pgLogin.jsp" }
- Gregt_33960
Nimbostratus
Hello, - Nicolas_Menant
Employee
Hi, - Gregt_33960
Nimbostratus
- hoolio
Cirrostratus
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? } } }
- Gregt_33960
Nimbostratus
Aaron,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects