Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

How do I create Sequential or Linked iRules?

So I'm a bit of an F5 novice, so please forgive me if this question is stupid.

I have an iRule currently which is programmatically updated by a web app as web applications are deployed.  It works great.  Basically it redirects PRODSITE.COM/CLIENTSPECIFCURI to a PRODSERVERPOOL based on /CLIENTSPECIFICURI.

I'd like to create an iRule ahead of it such that anything arriving to TESTSITE.COM goes to TESTSERVERPOOL.  Because of the programatically generated nature of the PRODSITE iRule, I'd like to avoid putting code into it if possible.

Can anyone shed some light on this for me?
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
You can assign multiple iRules to a given virtual.  Just use the "priority" command to tell the LTM what order to process them in.  Details are in the "priority" API documentation in the iRules wiki at


I believe I wrote an article on iRule events a while back too that might shed some light onto things.


Hope that helps...

-Joe
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Joe,

Thanks for the help.

Having read your tutorial, I think I may have phrased my question badly.

What I was hoping to do was basically:

If host == testsite, go to pool testsite
If host != testsite, go to iRule prodsite

Since that isn't possible, how do I do a rule where it checks if the host = testsite, and, if not, does nothing? Presumably then the next rule in the priority order would take effect (in this case the programatically generated iRule looking at URIs).

Thank you so much for your help.
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
That get's a little more difficult as there isn't a direct way to call an iRule from another iRule. What you'll need to do is to create a session variable to handle state and you.  Here's some pseudo code that may help

priority 100
when HTTP_REQUEST {
  set PROCESS_IRULE_PRODSITE 1;

  if { [HTTP::host] eq "testsite" } {
    # Assign target pool (if this is the default pool, this can be omitted).
    pool testsite
    # Do not process prodsite iRule
    set PROCESS_IRULE_PRODSITE 0;
  }
}

priority 200
when HTTP_REQUEST {
  if { $PROCESS_IRULE_PRODSITE == 1 } {
    # Do something
  }
}

I think that's what you are going after.

-Joe
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Are there only the 2 rules assigned to the VIPs doing Pool assignment?

As if that's the case, couldn't you just use 'Event disable' in your test iRule if it's a test connection...

 
when HTTP_REQUEST {
 if { [HTTP::host] eq "testsite" } {
    # Assign target pool (if this is the default pool, this can be omitted).
    pool testsite
    # Do not process prodsite iRule
    event disable
  }
}


Cheers
Gav
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Joe,

Thanks, I'll give that a shot!

Gavin,

Yes, there are the only two iRules. I'll try that one as well.

Thank you both so much for your help.
0