Forum Discussion
yaoxu_11146
Nimbostratus
Aug 01, 2008is it possible to write an iRule redirecting http requrest based on URI, but doesn't require http/fasthttp profile support?
we got a painful issue as describled in post http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=26481&view=topic
In short, we need to do http request redirection based on URI,...
spark_86682
Aug 01, 2008Historic F5 Account
You could do something close with just a TCP profile. Something like:
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set idx [string first " HTTP/1." [TCP::payload]]
if { $idx < 0 } {
if { [TCP::payload length] > 2048 } {
log local0. "ERROR! Could not find HTTP request in 2K! dropping..."
reject
} else {
Not enough data yet; collect more
TCP::collect
}
return
}
set request [string tolower [TCP::payload $idx]]
if { $request contains " /XXXXX" } {
pool Pool_XXXXX
} else {
pool Pool_WWWWW
}
}
I have not even tested the above to see if it compiles, much less works, but it should be a good starting point. Basically, since HTTP requests start with " HTTP/", this just collects enough TCP data to find that "HTTP/1." string, and calls everything before that the "request".
Then, since you're doing starts_with and the request variable also contains the HTTP method, you'd need to do a contains " /XXXXX". In other words, that space in the string before the /XXXXX is important. If you prefer, you can (just after the string tolower line) find the first space in request and chop off all the characters up to it. Then, request should just have the URI and you can go back to starts_with.
Makes sense?
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