Forum Discussion

dp_119903's avatar
dp_119903
Icon for Cirrostratus rankCirrostratus
Mar 17, 2014

Simple Logout redirect irule

I have some sites that I need to redirect to an external URL. I have figured that out with an irule

when HTTP_REQUEST {
    HTTP::redirect "https://OTHERSITE.com[HTTP::uri]"
}

On the external sites there is a "logout" button and that needs to hit a static web page that I have set up on the BIG-IP.

So if a user goes to www.example.com they get redirected to www.othersite.com. While on www.othersite.com if they click logout it sends them back to www.example.com/Logout.html.

I setup an irule and applied it to the same virtual server above the first redirect iRule. My thought is that the "www.example.com/Logout.html" is a specific URL so if the F5 sees that then to redirect it to the apology page, but if it sees anything else to just send it to the "OTHERSITE.COM" url. I'm sure I'm missing something but here's my other irule.


when HTTP_REQUEST {
 if { ([HTTP::host] equals "http://example.com/Logout.html") } {
         "/generic_apology_pic.jpg" { HTTP::respond 200 content [ifile get "generic_apology_pic.jpg"] }
         default { HTTP::respond 200 content [ifile get "generic_apology.htm"] }
      }
   }
}

I probably wrote this as confusing as possible, but very simply I need to redirect all traffic to www.example.com to www.othersite.com, unless it's going to www.example.com/Logout.html, at which point I need to display a page that is hosted on the F5.

Thanks in advance,

David

  • Try this:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::uri]] {
            "/logout.html" {
                HTTP::respond 200 content [ifile get "generic_apology.htm"] 
            }
            "/generic_apology_pic.jpg" { 
                HTTP::respond 200 content [ifile get "generic_apology_pic.jpg"] "Content-Type" "image/jpeg"
            }
        }
    }
    
  • Forgot that part:

    when HTTP_REQUEST {
        switch [string tolower [HTTP::uri]] {
            "/logout.html" {
                HTTP::respond 200 content [ifile get "generic_apology.htm"] 
            }
            "/generic_apology_pic.jpg" { 
                HTTP::respond 200 content [ifile get "generic_apology_pic.jpg"] "Content-Type" "image/jpeg"
            }            
            default {            
                HTTP::redirect "https://www.ohersite.com[HTTP::uri]"
            }
        }
    }