Forum Discussion
keefyweefy
Jul 08, 2011Nimbostratus
irule to redirect and amend URI
Hi
I'm trying to write a redirect irule but not having much joy.
The irule firstly needs to identify wireless clients then direct them to poolA
Then it needs...
Colin_Walker_12
Jul 08, 2011Historic F5 Account
What version are you running? I'm assuming version 9.x since you're still using matchclass. If that's the cast, and it were me, I'd write it something like this:
when CLIENT_ACCEPTED {
if { ([matchclass [IP::client_addr] equals $::Wireless]) || !([IP::addr [IP::client_addr] equals 192.168.0.0/16]) } {
set pool "poolA"
} else {
set pool "poolB"
}
}
when HTTP_REQUEST {
if { ($pool eq "poolB") && ([HTTP::uri] eq "/")} {
HTTP::redirect "/newuri"
} else {
pool $pool
}
}
By doing all of the IP lookups in the CLIENT_ACCEPTED event you're saving a fair amount of cycles for every HTTP request past the first one, which is generally a lot since there are 35-50 requests required to load the average web page. Take into account browsing multiple pages per connection and you'll save a heap of resources by getting as much logic into CLIENT_ACCEPTED as you can. I also tightened up a couple of the logical statements, but that's just how they make sense to me, there are lots of options on how to write them.
That being said, that's assuming you want to use HTTP::redirect for some reason. If you can get away with the HTTP::uri command like Peter mentioned, that's one less set of requests that need to be made and should be faster for your clients, just keep in mind that it behaves very differently.
Colin
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