Forum Discussion
danra_139044
Altostratus
May 05, 2014iRules: How to avoid HTTP_RESPONSE from rule 2 affect rule 1
When I added an HTTP_RESPONSE on rule 2, when rule 1 gets processed, it inserts the header from rule 2.
Is there a way to discriminate processing both HTTP_RESPONSES? I tried to set priority to 501,...
Kevin_Stewart
Employee
May 05, 2014I have to assume you're simplifying the iRules for forum consumption, but I would point out one very important aspect of "stacking" iRules. When you apply multiple iRules to a single VIP, and those iRules have the same events in them, the compiler will mesh all of the same events together. So in your example, the compiled iRule might look something like this:
when HTTP_REQUEST {
if { [HTTP::path] contains "did725"} {
pool mypool
}
if { [HTTP::path] contains "did825"} {
...doing nothing...
}
}
when HTTP_RESPONSE priority 501 {
if { [HTTP::status] == 200 } {
HTTP::header insert name value
}
}
So if you think about in this way, and given what (I believe) your requirement is, it may be easier to use a single iRule and adjust the syntax accordingly:
when HTTP_REQUEST {
if { [HTTP::path] contains "did725"} {
pool mypool
} elseif { [HTTP::path] contains "did825" } {
set hdr_insert
}
}
when HTTP_RESPONSE {
if { ( [info exists hdr_insert] ) and ( [HTTP::status] == 200 ) } {
unset hdr_insert
HTTP::header insert name value
}
}
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