Forum Discussion
iRules: 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, but since there's no other HTTP_RESPONSES defined, it still inserted the header during processing of traffic.
rule 1:
when HTTP_RESQUEST {
}
rule 2:
when HTTP_REQUEST {
}
when HTTP_RESPONSE priority 501 {
HTTP::header insert
}
4 Replies
- Kevin_Stewart
Employee
So you don't want the HTTP_RESPONSE event to get triggered (based on some criteria I presume)?
At a minimum you could do something like this in your HTTP_REQUEST event:
event HTTP_RESPONSE disable - danra_139044
Altostratus
So it would look something like below? I will give it a try. rule 1: when HTTP_REQUEST { if { [HTTP::path] contains "did725"} { pool mypool } } event HTTP_RESPONSE disable rule 2: when HTTP_REQUEST { if { [HTTP::path] contains "did825"} { } when HTTP_RESPONSE priority 501 { if { [HTTP::status] == 200 } { HTTP::header insert name value } } - Kevin_Stewart
Employee
I 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 } } - danra_139044
Altostratus
Kevin,
That makes sense. Alright, I will give it a shot.
Thanks much!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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