Forum Discussion
Irule to match and redirect on port / URI condition
Heres what we a re trying to do..
Got a number of sites using a single IP address on http, depending on the URL we want to re-direct to another port with a new URL then drop to a specific pool based on the port chosen. its like a double match
I have come up with this Irule, but im not convinced it will work.
We want to stick with "Switch" if possible as this is our general standard...
when HTTP_REQUEST {
switch [string tolower [HTTP::host] [TCP::local_port]] {
"site1.somesite.com" {
HTTP::redirect "http://site1.somesite.com:8001/App1[HTTP::uri]"
return
}
"site2.somesite.com" {
HTTP::redirect "http://site2.somesite.com:8002/App2[HTTP::uri]"
return
}
"8001" {
pool site1
}
}
"8002" {
pool site2
}
}
}
3 Replies
Hi,
I think that the irule below should work for you :
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "site1.somesite.com" { HTTP::redirect "http://site1.somesite.com:8001/App1[HTTP::uri]" return } "site2.somesite.com" { HTTP::redirect "http://site2.somesite.com:8002/App2[HTTP::uri]" return } "*:8001" { pool site1 } "*:8002" { pool site2 } } }
Actually Having thought about it, I guess that I could just build the Virtual Servers to listen on the Return ports..
when HTTP_REQUEST {
switch [string tolower [HTTP::host] [TCP::local_port]] { "site1.somesite.com" { HTTP::redirect "http://site1.somesite.com:8001/App1[HTTP::uri]" return } "site2.somesite.com" { HTTP::redirect "http://site2.somesite.com:8002/App2[HTTP::uri]" return } } }
Then the return http :port would just be collected by the other VIP and forwarded to the relevant Pool attached to that VS
Recent Discussions
Related Content
* 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