Forum Discussion
Gbps_31870
Aug 14, 2011Nimbostratus
using localvar to manage iRules process flow
Hi All,
I really appreciate your efforts in this wouderful forum.
I have a question which might solve the logs generated for TCL error for multiple redirection.
I have two irules, irule1 and irule2, and both are for HTTP redirection. I know that event disable is based on the connection rather than request which might cause subsequent requests bypassing that event, so I'm trying to avoid it.
irule 1
when HTTP_REQUEST {
switch [string tolower [HTTP::path]] {
"/xyz" {
HTTP::redirect "http://www.example.com/dir1/dir2/xyz"
set stop_processing 1
}
}
}
irule 2
when HTTP_REQUEST {
if {($stop_processing != 1)
body
}
}
My goal is to skip irule 2 if and only if irule 1 is processed for that connection, my questions are:
1- if there is no hit for irule 1, will be there any issues that prevent irule 2 from processing the request, as the localvar (stop_processing) has no value?
2- The localvar is per connection, so no need to worry about multiple/parallel connections, but what about subsequent HTTP_REQUEST during the same connection, is it possible to create irule 3 as below and associate it with the same VS to chenge localvar value.
when HTTP_RESPONSE {
set stop_processing 0
}
BR,
- Ed_Hammond_2611NimbostratusBefore reading a variable it must be set somewhere or an exception will occur. In the first iRule, add a "set stop_processing 0" before the switch statement so it will always be set to some value. Another approach is to bullet proof the second iRule test with something like
which survive if the first iRule is not in the chain of execution.if {[catch {set stop_processing}] or $stop_processing != 1} { do stuff }}
- Gbps_31870NimbostratusThanks Hammond, I would like to go with the first option as you mentioned (setting localvar in the first iRule).
- Colin_Walker_12Historic F5 AccountYou can also use the info exists command, such as:
if {[info exists $stop_processing]} { ... }
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