Forum Discussion
jholmes_39917
Jun 25, 2012Nimbostratus
URI client IP redirect
I am new to this group and irules so bare with me here. What I have is a site whos owners want a redirect to happen based on client ip range, and URI.
Example of what I have so far:
when HTTP_REQUEST{
log local. "Client: [IP::client_addr]"
if { [HTTP::uri] starts_with "URI" }{
if { [IP::addr [IP::client_addr] equals X.X.X.X/X] } {
pool blah }
elseif { [IP::addr [IP::client_addr] equals X.X.X.X] } {
pool blah }
}
}
This doesnt appear to work and was hoping someone could give me some pointers on getting this accomplished.
- hooleylistCirrostratusThat looks about right. I assume URI is a liternal URI like /path/to/file? Can you add debug logging for the two different pool statements to see if either are being hit?
- jholmes_39917Nimbostratus[undefined procedure: elseif] [elseif { [IP::addr [IP::client_addr] equals XXXX] } { Havent gotten a chance to debug it. I get this error when trying to save it through the IRule editor.
- jholmes_39917Nimbostratus[undefined procedure: elseif] [elseif { [IP::addr [IP::client_addr] equals XXXX] } { Havent gotten a chance to debug it. I get this error when trying to save it through the IRule editor.
- hooleylistCirrostratusI'd guess you have a space issue with the elseif clause. Can you try this?
when HTTP_REQUEST { log local. "Client: [IP::client_addr]" if { [HTTP::uri] starts_with "/some_uri" }{ if { [IP::addr [IP::client_addr] equals X.X.X.X/X] } { pool blah log local. "[IP::client_addr]: Matched first check" } elseif { [IP::addr [IP::client_addr] equals X.X.X.X] } { pool blah log local. "[IP::client_addr]: Matched second check" } else { reject } } }
- jholmes_39917NimbostratusOk that appears to load successfully and logs my IP correctly. The problem I have is the criteria above should only be allowed to the site. My IP still reaches the backend IP addresses and can see the content. Is there something I can use that will stop that from happening?
- naladar_65658AltostratusDo you have a default pool setup on the virtual by chance?
- jholmes_39917Nimbostratus@naladar -- I do have one yes. Do I need to turn that off?
- naladar_65658AltostratusI would recommend giving that a shot. Your iRule is looking for two things, otherwise traffic will "fall through" essentially and go to whatever you have set for a default pool.
- hooleylistCirrostratusOr you could add an else clause with a reject statement to send a TCP reset if that condition is met. I edited the example above to show this.
- jholmes_39917NimbostratusThanks everyone for the help. Works like a champ I am really enjoying this F5 and its abilities... :-)
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