Forum Discussion
jayanthi_41101
Aug 31, 2011Nimbostratus
Multiple irules that have same events
I have 2 irules that have 2 datagroups and redirects to different pool but handles the same events HTTP_REQUEST and HTTP_RESPONSE. Will all the requests go through both irules even if the da...
hooleylist
Aug 31, 2011Cirrostratus
I guess the important question is what do you want the behavior to be?
By default, if rule1 is listed first in the order of iRules added to the virtual server its events will run first. For example if this was your virtual server config:
virtual http_vs {
snat automap
pool http_pool
destination 10.1.0.15:80
ip protocol 6
rules {
rule1
rule2
}
profiles {
http {}
tcp {}
}
}
And rule1 and rule2 both had HTTP_REQUEST and HTTP_RESPONSE events, when the HTTP request headers are parsed from the client rule1's HTTP_REQUEST event would be triggered then rule2's HTTP_REQUEST event would be triggered. When the pool member responds, rule1's HTTP_RESPONSE event would be triggered followed by rule2's HTTP_RESPONSE event.
The variables from rule1 would be available to rule2. If you use the same variable name in rule2 it would overwrite the value rule1 set. In your example, rule2 would overwrite the value for a1 in its HTTP_REQUEST event. When rule1 references a1 in HTTP_RESPONSE, it would be using the value that rule2 assigned in its HTTP_RESPONSE.
There are a few ways you can affect this behavior. You can override the default priority of an iRule or events within an iRule using the priority command:
http://devcentral.f5.com/wiki/iRules.priority.ashx
You can also use unique variable names across the two iRules if you want to avoid conflicts between the two iRules. You could also combine the iRules to make these dependencies more clear.
You could also disable individual events or all subsequent events using the event disable command. I try to avoid this as I think it's a sledgehammer approach that can cause problems in the future if you need to add more iRules to a virtual server. But the option is there.
http://devcentral.f5.com/wiki/iRules.event.ashx
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects