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, however we can't use neither of http or fasthttp profile. by default, http or fasthttp profile is required for a iRule as below:
when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/XXXXX"} {
pool Pool_XXXXX
} elseif {[string toupper [HTTP::uri]] starts_with "/YYYYY"} {
pool Pool_YYYYY
} else {
pool Pool_WWWWW
}
}
so, is it possible to write an iRule redirecting http requrest based on URI, but doesn't require http/fasthttp profile support?
6 Replies
- spark_86682Historic F5 AccountYou 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 } }
- yaoxu_11146
Nimbostratus
unfortunately, after i applied this iRule to our site, the whole site is not accessible. I checked the iRule line by line, but failed to figure out while line blocked the access. - Nicolas_Menant
Employee
You may need a TCP::release at the end of the iRule - yaoxu_11146
Nimbostratus
thanks for nmenant's reply, after adding 'tcp::release', users CAN be guided to the default pool pool_WWWWW, but the redirection to pool_XXXXX doesn't work, sorry i'm new to iRule, and can't figure out why...anybody could give me a hand? - Andy_Herrman_22
Nimbostratus
Try throwing some logging in place: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]] log local0. "Got request: $request" if { $request contains " /XXXXX" } { log local0. "Sending to Pool_XXXXX" pool Pool_XXXXX } else { log local0. "Sending to Pool_WWWWW" pool Pool_WWWWW } }
- Nicolas_Menant
Employee
the logging will be in /var/log/ltm.
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