Forum Discussion
Neil_66348
Nov 09, 2010Nimbostratus
iRule GeoIP Targeting
Hi Guys ,
We're looking to implement some targeting thats found in 10.2 on our F5's.
Performing matching at the IP level works fine , I've found some example code for matching to the internal quova database. The example below as pulled from an article on the F5 website , however can't seem to get it to compile.
We've created an iRule data Group list of type String as well.
when HTTP_REQUEST {
set region [class match -value [whereis [IP::client_addr] abbrev] equals uk_regions]
if { $region ne "" } {
switch $region York { pool $region }
Greater London { HTTP::redirect http://dev.application.com/grlondon }
Leeds { HTTP::redirect http://dev.application.com/leeds}
Stockport { HTTP::redirection http://dev.application.com/stockport }
} else { pool devpool }
}
When going to complile I get the errors o:
line 4: [wrong args] [switch $region]
line 5: [undefined procedure: York] [York { pool $region }]
line 6: [undefined procedure: Greater] [Greater London { HTTP::redirect http://dev.application.com/grlondon }]
line 7: [undefined procedure: Leeds] [Leeds { HTTP::redirect http://dev.application.com/leeds}]
line 8: [undefined procedure: Stockport] [Stockport { HTTP::redirection http://dev.application.com/stockport }]
Any help greatly appreciated.
many Thanks
Nei
- naladar_65658AltostratusHey Neil,
when HTTP_REQUEST { set region [class match -value [whereis [IP::client_addr] abbrev] equals uk_regions] if {$region ne ""}{ switch $region { "York" { pool $region } "Greater London" {HTTP::redirect http://dev.application.com/grlondon} "Leeds" {HTTP::redirect http://dev.application.com/leeds} "Stockport" {HTTP::redirect http://dev.application.com/stockport} default {pool devpool} } } }
- L4L7_53191NimbostratusNice one!
- Neil_66348NimbostratusHi ,
- naladar_65658AltostratusI am not certain but it looks like to me you are setting your state to equal the two letter abbreviation in the iRule. But you want to actually return the word, not the two letter abbrev so using state instead of abbrev in the iRule and I think this should work:
when HTTP_REQUEST { set state [class match -value [whereis [IP::client_addr] state] equals uk_regions] if {$state ne ""}{ switch $state { "Greater London" {HTTP::redirect http://62.190.x.x/ab/grlon/} "Leeds" {HTTP::redirect http://62.190.x.x/ab/leeds} "York" {HTTP::redirect http://62.190.x.x/tv/York/} default {pool TIN-HTTP-POOL} } } }
- naladar_65658AltostratusJust in case other folks are looking at using Geolocation here is an excellent article written by Jason on the subject:
- Neil_66348NimbostratusHi ,
- Neil_66348NimbostratusHi Guys ,
- naladar_65658AltostratusI have never used it before, but I am very curious if something like this would work? It does compile, I am just uncertain of the ramifications of using event disable in an iRule:
when HTTP_REQUEST { set state [class match -value [whereis [IP::client_addr] state] equals uk_regions] if {($state ne "")}{ switch $state { Leeds { pool $region } York {if { [HTTP::uri] starts_with "/ab/york"} { event HTTP_REQUEST disable } else { HTTP::redirect http://62.190.1.1/ab/york } } grlond {HTTP::redirect http://www.google.com/news} default {pool DEV-HTTP-POOL} } } }
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