Forum Discussion

scarpozzi_82104's avatar
Icon for Nimbostratus rankNimbostratus
Dec 09, 2010

Redirection when clients are at /

I've got a portal server that will be unavailable weekly due to some oracle cold backups. I've got an iRule that sets up the maintenance window and gives me controls to automate the recurring window.



My portal server listens on 80/443 in 2 pools/virtual servers. When the database goes down for backups, I have Apache spin up another instance listening on port 81 for the maintenace I created a maintenance pool.



To handle requests during the maintenace window, the command I have is:



use pool maint_pool



I tested this and it works great. The problem is, when a user is logged into the portal and it goes down for maintenance, they get a 404 because the pool switches out from under them. I need a redirect for established connections and the 'use pool maint_pool' for new connections.



To get what I want, I'm going to need a redirect when the maintenance window is on and the HOST:URI doesn't match What iRule functions allow you to compare the client URL and do a redirect when it isn't '' or ''





2 Replies

  • An HTTP client cannot send a null URI. Something like this should do:

    when HTTP_REQUEST {
        Check for anything not
       if {"[string tolower [HTTP::host]][HTTP::uri]" eq ""}{
          pool maint_pool
       } else {
          HTTP::redirect ""

    This assumes that doesn't reference any other URIs under If it did, you could add them to a switch statement:

    when HTTP_REQUEST {
        Check for host of
       if {[string tolower [HTTP::host]] eq ""}{
           Check if URI is a maintenance URI
          switch -glob [HTTP::uri] {
             "/maint/*" -
             "/maintenance.jpg" -
             "/maintenance.css" -
             "/maintenance.html" {
                pool maint_pool
        If we're still in the iRule, the request wasn't for a maintenance URI, so redirect the request
       HTTP::redirect ""

  • Thank you so much!



    The second example was exactly what I was looking for. I was able to do the redirect and still provide the maintenance URI needed. I really appreciate it!