Forum Discussion
Mohammed_Moin_2
Nimbostratus
Sep 20, 2018redirect to URI based upon client public
How to redirect traffic to certain uri based upon client public IP
Lee_Sutcliffe
Nacreous
Sep 20, 2018Hi Mohammed,
I've put together a more comprehensive iRule now I have more information about your requirements which should give you a good starting point. It uses a data-group using IP addresses and URIs as key/pair values.
The iRule will lookup the client IP against the datagroup elements, if there is a match it will return the data portion of the element (the URI) and set the outgoing URI to this value.
Please note this iRule hasn't been tested.
Datagroup
ltm data-group internal user_mapping_dg {
records {
10.10.10.1 {
data /uri1
}
10.10.10.2 {
data /uri3
}
10.10.10.3 {
data /uri3
}
}
type string
}
iRule
when HTTP_REQUEST {
set mapping_dg "user_mapping_dg"
return data-group element (IP address) if client IP is listed. returns NULL/"" if not
set ipMapping [class match -name [IP::addr [IP::client_addr]] equals $mapping_dg]
if {$ipMapping ne ""} {
set custom URI based on client IP - set in coresponding data portion of data-group
set customUri [class match -value $ipMapping equals $mapping_dg]
HTTP::uri $customUri
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
