Forum Discussion

nrelihan_68143's avatar
nrelihan_68143
Icon for Nimbostratus rankNimbostratus
Jul 08, 2011

Redirecting 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

 

 

When somebody goes to www.fakewebsite.com it looks at their dns location and redirects it to their a regional website, in my example here, its Ireland and UK. So when somebody goes to this website when in Ireland it will redirect them to www.fakewebsite.com/ireland and to www.fakewebsite.co.uk when in the UK.

 

I have two pools setup, one for ireland and one for the UK.

 

 

Global traffic irule

 

 

when DNS_REQUEST {

 

if {[whereis [IP::client_addr]] contains "IE"} {

 

pool pool-Ireland

 

} elseif {[whereis [IP::client_addr]] contains "GB"} {

 

pool pool-UK

 

} else {

 

pool pool-default

 

 

pool-UK Local traffic irule

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] equals "/" } {

 

HTTP::respond 302 Location "http://www.fakewebsite.com/ireland/"

 

}

 

}

 

 

pool-Ireland Local traffic irule

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] equals "/"} {

 

HTTP::respond 302 Location "http://www.fakewebsite.co.uk/"

 

}

 

}

 

 

 

What Im looking to do

 

 

 

Im looking to enhance this like so:

 

For example when somebody is located in the UK types www.fakewebsite.com/pictures the irule would redirect them to the UK website but including the static page they requested, www.fakewebsite.co.uk/pictures.

 

When somebody is located in irealnd they type www.fakewebsite.com/pictures the irule would redirect them to www.fakewebsite.com/ireland/pictures.

 

 

What I'm afriad though is that if somebody based in Ireland but for some reason had a UK ip address and visa versa, typed in www.fakewebsite.com/ireland, it would still re-direct them to the .co.uk website. So in other words they would never be able to get to the .com/ireland website.

 

So would it be possible to include a rule that would not allow this to occur.

 

Maybe the rule might say, if they type in www.fakewebsite.com/ireland, do not put it though an irule?

 

 

Any help is appreciated, my brain is melting trying to get working code for this!

 

 

Thanks alot!

 

 

Neil

 

19 Replies