Forum Discussion

Mel_153429's avatar
Mel_153429
Icon for Nimbostratus rankNimbostratus
Dec 02, 2015
Solved

I need help creating an IRULE that redirect if pool members are down and url ends with /VCS

Hello,

 

I need help creating an IRULE that meets two conditions. If the pool members are down and it the url ends with /vcs. The pool is for a sharepoint site and just want to be redirected for a specific site for sharepoint.

 

  • If no pool members are up, LB_FAILED will be triggered. It can be triggered for other reasons, but perhaps you wish to redirect any time that the traffic cannot be forwarded because of a failure? If so:

    when HTTP_REQUEST {
        if { [HTTP::path] ends_with "/VCS" } {
            set vcs 1
        }
        else {
            set vcs 0
        }
    }
    
    
    when LB_FAILED {
        if { $vcs } {
            HTTP::redirect "http://www.site.com"
        }
    }
    

    The variable

    $vcs
    must be set in HTTP_REQUEST because the Request Host header is not available in LB_FAILED.

7 Replies

  • R_Marc's avatar
    R_Marc
    Icon for Nimbostratus rankNimbostratus

    something like this should do that. I'm not convinced this would be the best way to deal with the condition, but it satisfy your stated goal, I think.

    if{ [string tolower [HTTP::path]] starts_with "/vcs" }  {
       Assume the worst
      set CATASTROPHE 1
      foreach { pmem } [members -list yourpool] {
       scan $pmem {%[^ ] %s} ip port
       if { [LB::status pool yourpool member $ip $port] eq "up" } {
           set CATASTROPHE 0 
       }
      }
      if { $CATASTROPHE } {
         HTTP::respond 302 Location "http://www.domain.org"
      } else {
         Catastrophe averted!
      }
    }
    

    That's a redirect method. Another option would be just to select another backend utilizing a pool command, but that would be better handled utilizing priority groups and avoiding an iRule all together.

  • If no pool members are up, LB_FAILED will be triggered. It can be triggered for other reasons, but perhaps you wish to redirect any time that the traffic cannot be forwarded because of a failure? If so:

    when HTTP_REQUEST {
        if { [HTTP::path] ends_with "/VCS" } {
            set vcs 1
        }
        else {
            set vcs 0
        }
    }
    
    
    when LB_FAILED {
        if { $vcs } {
            HTTP::redirect "http://www.site.com"
        }
    }
    

    The variable

    $vcs
    must be set in HTTP_REQUEST because the Request Host header is not available in LB_FAILED.

    • Mel_153429's avatar
      Mel_153429
      Icon for Nimbostratus rankNimbostratus
      Hello, vernon Thanks for your respond! The requirement that's being ask if they have to take SharePoint down for patching they want to redirect users that's hitting /VCS site to point to another website until patching is complete.
    • Mel_153429's avatar
      Mel_153429
      Icon for Nimbostratus rankNimbostratus
      Hello the irule worked great for my needs. I just had to add one line to make it work. HTTP::uri [string toupper [HTTP::uri]] Thanks for the help !
  • Vernon_97235's avatar
    Vernon_97235
    Historic F5 Account

    If no pool members are up, LB_FAILED will be triggered. It can be triggered for other reasons, but perhaps you wish to redirect any time that the traffic cannot be forwarded because of a failure? If so:

    when HTTP_REQUEST {
        if { [HTTP::path] ends_with "/VCS" } {
            set vcs 1
        }
        else {
            set vcs 0
        }
    }
    
    
    when LB_FAILED {
        if { $vcs } {
            HTTP::redirect "http://www.site.com"
        }
    }
    

    The variable

    $vcs
    must be set in HTTP_REQUEST because the Request Host header is not available in LB_FAILED.

    • Mel_153429's avatar
      Mel_153429
      Icon for Nimbostratus rankNimbostratus
      Hello, vernon Thanks for your respond! The requirement that's being ask if they have to take SharePoint down for patching they want to redirect users that's hitting /VCS site to point to another website until patching is complete.
    • Mel_153429's avatar
      Mel_153429
      Icon for Nimbostratus rankNimbostratus
      Hello the irule worked great for my needs. I just had to add one line to make it work. HTTP::uri [string toupper [HTTP::uri]] Thanks for the help !