Forum Discussion

El_Jefe's avatar
El_Jefe
Icon for Nimbostratus rankNimbostratus
Jul 31, 2011

Need 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's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    Assuming you have two VS's with unique iRUles. On the HTTP one you just need

      HTTP::redirect "https://[HTTP::host]/Application/
    

    and on the HTTPS one you need to detect the URI and redirect appropriately

    if { {[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

  • 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

     

  • Hi El Jefe,

     

    Do you have any auto-refresh or reload webpage on the content within /Application?

     

     

    Bhattman

     

  • Yes, it auto-reloads every so often as it has dynamic content on the first page.

     

  • 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.
  • 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.
  • 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.
  • hi El_Jefe,

    You can also use the switch command

    
    when 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
  • 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