Forum Discussion
webguy9_97931
Nimbostratus
May 22, 2007iRule proxy
Hello,
I am looking to proxy requests based on:
1) UserAgent (bot detection)
2) URL patterns (foo\.html)
How do I set up the iRule to handle this?
Thanks!
May 22, 2007
For bot detection, here is a sample in CodeShare that shows how to detect a bot via the "User-Agent" http header.
http://devcentral.f5.com/wiki/default.aspx/iRules/ControllingBots.html
Click here
As for url patterns, the easiest way is to use a switch statement with file globbing (star based wildcards)
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"*foo.html" {
do something
}
"/path/*" {
do something else
}
"/dir1/*" -
"/dir2/*" -
"/dir3/*" {
do something if either of the above 3 match.
}
}
}
The basics here is that the URI is available with the HTTP::uri command in the HTTP_REQUEST event. You can assign that to a variable and do if/else statements, a switch statement (shown above), a match to a class list (as shown in the ControllingBots sample code).
Hope this helps...
-Joe
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