Forum Discussion

sundogbrew's avatar
sundogbrew
Icon for Altocumulus rankAltocumulus
Jul 30, 2014

Irule redirect question

So I wrote a real simple Irule that redirects if all the nodes are out of the pool

 

when HTTP_REQUEST { if { [active_members [LB::server pool]] == 0 } { HTTP::redirect "https://blablabla.com" } }

 

My question is can an I rule take info out of the URL or URI and redirect based on that?

 

So say my URL is https://funnyapplication.blabla.com and there are no nodes in the pool, can my Irule redirect to say Https://replacementurl/funnyapplication.bla.com where it grabs some piece of the url and puts it in the URI of the redirect path? Thanks as always! Joe

 

3 Replies

  • Absolutely.

    when HTTP_REQUEST {
        if { [active_members [LB::server pool]] < 1 } {
            HTTP::redirect "https://replacementurl/[HTTP::host][HTTP::uri]"
        }
    }
    
  • Hey Kevin, Thanks for your help. I'm not quite there yet...

     

    So that works to replace the the URL but I need to take the end off of it. So my URL is https://pto.something.com/bla/bla/bla What you wrote works but my problem is I only need the pto part. So my redirect should be https://redirect.something.com/pto/bla/bla is this still doable? Thanks Joe

     

  • Just for my own edification, why would you not simply configure that in the fallback host in the http profile?