Forum Discussion

ryan_rockwell_1's avatar
ryan_rockwell_1
Icon for Nimbostratus rankNimbostratus
Jan 06, 2014

Need help combing or stacking iRules

I have 2 iRules that I either want to: 1. get working in a stacked configuration so it reads the first rule and if it's not relevant, act on the 2 rule. 2. combine the 2 rules so that the first section is read and either acted upon or ignored and then the second section takes affect.

 

If I place the rules individually on the VS they work as expected.

 

If I place them in a stacked config on the VS the first rule fails and the connection is reset.

 

If I combine them the first section fails when activated and the connection fails. the second section will work if the condition of the first section is false.

 

Rule 1: when HTTP_REQUEST { if {[active_members RHW-QA-RHW-HTTP] < 1} { pool RHW-QA-RHW-HTTP-PH } }

 

Rule 2 when HTTP_REQUEST { set DEBUG 0 if { $DEBUG } { log local0. "Request: [HTTP::uri]" } switch -regex [string tolower [HTTP::uri]] { "^/jobsearch.*" - { if { $DEBUG } {log local0. "Sending request to RHW-QA-RHW-HTTP-APP" } pool RHW-QA-RHW-HTTP-APP } default { pool RHW-QA-RHW-HTTP} } }

 

2 Replies

  • If I combine them the first section fails when activated and the connection fails. the second section will work if the condition of the first section is false.

    how did you combine? is it something like this?

    when HTTP_REQUEST { 
      set DEBUG 0 
      if {[active_members RHW-QA-RHW-HTTP] < 1} { 
        pool RHW-QA-RHW-HTTP-PH 
        return
      }
       
      if { $DEBUG } { log local0. "Request: [HTTP::uri]" } 
      switch -regex [string tolower [HTTP::uri]] { 
        "^/jobsearch.*" { 
          if { $DEBUG } {log local0. "Sending request to RHW-QA-RHW-HTTP-APP" } 
          pool RHW-QA-RHW-HTTP-APP 
        } 
        default { 
          pool RHW-QA-RHW-HTTP
        } 
      } 
    }
    

    by the way, is regex really needed? can it be glob instead?

  • The answer worked great for me, many thanks. Now to complicate things even more. When it passes the LB check and is successful is redirecting to the secondary pool everything is great if the secondary pool is up. Where/how would I add a second set of checks to make sure that a server is available in the secondary pool? I'm thinking it would be after the switch but before the pool if that makes since.