Forum Discussion
Using [IP::addr [IP::client_addr] in HTTP_REQUEST event
Hi, I'm trying to use the IP address to redirect requests to a particular pool after the uri has been checked. I am getting the following error:
01070151:3: Rule [xxx_irule] error: line 15: [undefined procedure: elseif] [elseif { [IP::addr [IP::client_addr] equals 10.100.128.0/18 or 10.200.128.0/18] } { pool a_1_ism } elseif { [HTTP::uri] starts_with "" } { pool a_1_HTTP }]
Ive found a few suggestions in the forum, but none seem to apply.
Can anyone help? Thanks.
This is my irule
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/a1" } { pool a_1_HTTP } elseif { [HTTP::uri] starts_with "/a2" } { pool a_2 } elseif { [HTTP::uri] starts_with "/a3" } { pool a_3 } elseif { [HTTP::uri] starts_with "/health" } { pool a_1_HTTP_HEALTH } elseif { [HTTP::uri] starts_with "/ism" } { elseif { [IP::addr [IP::client_addr] equals 10.100.128.0/18 or 10.200.128.0/18 ] } { pool a_1_ism
} elseif { [HTTP::uri] starts_with "" } { pool a_1_HTTP } } }
- nitassEmployee
is close curly bracket of /ism condition missing?
} elseif { [HTTP::uri] starts_with "/ism" } { elseif { [IP::addr [IP::client_addr] equals 10.100.128.0/18 or 10.200.128.0/18 ] } {
- Kevin_StewartEmployee
There's a flaw in the logic, but not exactly sure what your intentions are. Here's the iRule reformatted approximation so you cane see what I mean:
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/a1" } { pool a_1_HTTP } elseif { [HTTP::uri] starts_with "/a2" } { pool a_2 } elseif { [HTTP::uri] starts_with "/a3" } { pool a_3 } elseif { [HTTP::uri] starts_with "/health" } { pool a_1_HTTP_HEALTH } elseif { [HTTP::uri] starts_with "/ism" } { elseif { [IP::addr [IP::client_addr] equals 10.100.128.0/18 or 10.200.128.0/18 ] } { pool a_1_ism } elseif { [HTTP::uri] starts_with "" } { pool a_1_HTTP } } }
-
Right below /ism URI check you're either missing some command, or attempting to drop into a subcondition (URI starts with /ism AND the IP address matches). If the latter, you're starting a condition block with an elseif instead of an if, which is what you're seeing in the errors.
-
For the IP address check, you'd actually need to do something like this:
{ ( [IP::addr [IP::client_addr] equals 10.100.128.0/18] ) or ( [IP::addr [IP::client_addr] equals 10.200.128.0/18] ) }
-
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