Forum Discussion
Rob_76452
Nimbostratus
Mar 15, 2010brand new please help redirect based on uri
My sys admin is saying this is really simple, you should already be done but I'm lost. My first experience with F5's. I think the request is simple if you know about F5 though. anyways..
I have a pool and I need it to go to /exchange if it is in the url and just go straight through if it is anything else. That is the request but really I believe he needs it to go to /exchange if it is in the url and /owa for everything else.
I am trying to read/digest the 101 stuff here. Please help if you can.
Thanks,
Rob
6 Replies
- The_Bhattman
Nimbostratus
Hi Rob,
here is an example of redirect based on URIwhen HTTP_REQUEST { if {[HTTP::uri] eq "/blahblah" } { HTTP::redirect "http://www.domain.com/something" } }
Here are some other examples in the Wiki iRule
Click here
Click here
I hope this helps
Bhattman - The_Bhattman
Nimbostratus
Hi Rob,
You can also take a look at the F5 Deployment Guides (Click here), for exchange/owa.
Bhattman - The_Bhattman
Nimbostratus
Hi Rob,
I suppose taking the same concept as I explained you can do the followingwhen HTTP_REQUEST { if {[HTTP::uri] eq "/exchange" } { pool exchange_pool } else { pool other_pool } }
Or you could right up using the SWITCH commandwhen HTTP_REQUEST { switch -glob [string tolower[HTTP::uri] { "/exchange" { pool exchange_pool } default {pool other_pool } } }
I hope this helps
Bhattman - naladar_65658
Altostratus
Glad you mentioned the SWITCH command Bhattman, it is perfect for something like this and requires the least amount of overhead to my knowledge. - Rob_76452
Nimbostratus
Hey thank you VERY much!!!! I think I got it working. My tests look good enough to pass back to the sysadmin. Here is what I came up with:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"exchange*" {
log local0. "Matched exchange uri for [HTTP::uri]"
pool tohtca-https
}
"owa*" {
log local0. "Matched owa uri for [HTTP::uri]"
pool tohtca-https
}
default {
log local0.debug "Matched default for [HTTP::uri]"
HTTP::uri "/OWA"
HTTP::uri "[HTTP::uri]OWA"
}
}
}
Thanks again! - hoolio
Cirrostratus
Hi Rob,
A relative URI should always start with a /, so I'm not sure how that example could be working if you don't have a / or * at the start of the URIs.
You can combine multiple switch cases that have the same action using syntax like this:when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/exchange*" - "/owa*" { log local0. "Matched exchange or owa uri for [HTTP::uri]" pool tohtca-https } default { log local0.debug "Matched default for [HTTP::uri]" HTTP::uri "/OWA" HTTP::uri "[HTTP::uri]OWA" } } }
Also, I'd check the default action to make sure that appending the string OWA to the end of any unmatched URI works. I'm not sure what else you have going through the VIP, but I could imagine that append breaking most other requests.
Aaron
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
