Forum Discussion
El_Jefe
Nimbostratus
Jul 31, 2011Need ideas for a "garbage collector" iRule
Hello,
I have been working with the F5 for a bit, and have written some simple iRules. However, I am getting a little stuck on this one. We are running an Oracle 11G Fusion Middleware app for a large university. We have recently added in this app to our F5, and I need some ideas.
In the past, we had "garbage collection" rules on the Apache server, so that it always re-directed requests to HTTPS and to the right virtual directory. Now, we have multiple Apache servers load balanced, and SSL is off loaded to the Virtual HTTPS server on the F5. If our users type in -
http://department.university.edu
OR
http://department.university.edu/
OR
https://department.university.edu
OR
http://department.university.edu/Application
We need it re-directed to
https://department.university.edu/Application/
and IF it comes in on https://department.university.edu/Application - leave it alone.... let it do it's thing.
Right now, If I run traffic through the F5, and they type it wrong, they get the "Welcome to Oracle Fusion Middleware" page, and that's kinda bad.
Any help would be GREATLY appreciated!
Thanks,
Jeff
9 Replies
- Hamish
Cirrocumulus
Assuming you have two VS's with unique iRUles. On the HTTP one you just needHTTP::redirect "https://[HTTP::host]/Application/
and on the HTTPS one you need to detect the URI and redirect appropriatelyif { {[HTTP::uri] equals ""} or { [HTTP::uri] equals "/"} pr { [HTTP::uri] equals "/Application" } { HTTP::redirect "/Application/" }
There's other ways to do that, but it depends on how complicated the testing needs to be... If the "/Application/" is variable, then you could use a datagroup/class to hold a list of valid URI's... (To detect the "/Application" and redirect to "/Application/")
H - El_Jefe
Nimbostratus
Yep - I do have to different Virtual Servers one for 80 and the other for 443.
I wrote a simple iRule this morning for my test environment, and it looks like this -
when HTTP_REQUEST {
HTTP::redirect "https://host.university.edu/Application/"
}
It re-directs to the HTTPS:, however, it is seeming to get caught in a loop, the page, loads over and over again...
there are no iRules on the HTTPS Virtual Server.
I think I'm getting close though. :-)
Jeff - The_Bhattman
Nimbostratus
Hi El Jefe,
Do you have any auto-refresh or reload webpage on the content within /Application?
Bhattman - El_Jefe
Nimbostratus
Yes, it auto-reloads every so often as it has dynamic content on the first page. - El_Jefe
Nimbostratus
I thought that the issue was that the HTTP VS was tied to the same pool resources. So, I removed that pool, since the HTTP VS is only doing a re-direct anyway, but that didn't seem to solve it. - El_Jefe
Nimbostratus
Plodding along.... I found that this works -
when HTTP_REQUEST {
HTTP::redirect "https://host.department.university.edu/Application/faces/oracle/webcenter/portalapp/pages/login.jspx"
}
Now on to the HTTPS rule. - El_Jefe
Nimbostratus
Here is what I finally settled on for the HTTPS rule -
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://host.department.university.edu/Application/faces/oracle/webcenter/portalapp/pages/login.jspx"
}
elseif { [HTTP::uri] equals "" } {
HTTP::redirect "https://host.department.university.edu/Application/faces/oracle/webcenter/portalapp/pages/login.jspx"
}
elseif { [HTTP::uri] equals "/application" } {
HTTP::redirect "https://host.department.university.edu/Application/faces/oracle/webcenter/portalapp/pages/login.jspx"
}
}
In the limited testing I've done, it seems to work. - The_Bhattman
Nimbostratus
hi El_Jefe,
You can also use the switch commandwhen HTTP_REQUEST { if { [HTTP::host] eq "host.department.university.edu" } { set URI "/Application/faces/oracle/webcenter/portalapp/pages/login.jspx" switch -glob [string tolower [HTTP::uri] { "/" - "/application" { HTTP::redirect "https://[HTTP::host]/$uri" } default { HTTP::redirect "https://[HTTP::host]/$uri } } } }
I hope this helps
Bhattman - hoolio
Cirrostratus
A couple of minor edits:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "host.department.university.edu" } {
switch [string tolower [HTTP::uri]] {
"/" -
"/application" { HTTP::redirect "https://[HTTP::host]/Application/faces/oracle/webcenter/portalapp/pages/login.jspx" }
default { HTTP::redirect "https://[HTTP::host]/Application/faces/oracle/webcenter/portalapp/pages/login.jspx" }
}
}
}
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
