Forum Discussion
nrelihan_68143
Nimbostratus
Jul 08, 2011Redirecting to regional website depending on user DNS.
Hey all, I'm quite new to F5 irules first of all.
Perhaps I'll tell you what I have working first and then explain to you what additional things I'd like to do.
What I have working...
The_Bhattman
Nimbostratus
Jul 08, 2011Hi Neil,
Well your code regarding detecting someone's location is based on the Geographic location based an IP address. So it's important to understand that people who use anonymous proxy systems can get around your iRule by appearing from different location. Some organization have gotten around this by simply locking out requests made by proxy systems. However, that would be something that you or your company would need to decide because there some request could be legitimate.
Assuming that your iRule is really a single Irule with 3 seperate events you can optimize code so that all logic is triggered on one event
when HTTP_REQUEST {
set hostname [string tolower [HTTP::host]]
switch -glob [whereis [IP::client_addr]] {
"IE" {
if {$hostname eq "www.fakewebsite.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::respond 302 Location "http://www.fakewebsite.com/ireland/" }
"/pictures" { HTTP::respond 302 Location "http://www.fakewebsite.com/ireland/pictures" }
}
pool pool-ireland
}
}
"GB" {
if {$hostname eq "www.fakewebsite.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::respond 302 Location "http://www.fakewebsite.co.uk/" }
"/pictures" { HTTP::respond 302 Location ""http://www.fakewebsite.co.uk/pictures" }
}
pool pool-UK
}
}
Default { pool pool-default }
}
}
I hope this helps
Bhattman
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