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!
- 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
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. } } }
- webguy9_97931
Nimbostratus
Thanks Joe... - You are going to have to tell me what you mean by "proxy". If you mean, send the traffic to a particular pool of servers, you can do that with the "pool" command. You can use the node command to send the request to a specific node:port destination. Check out the iRules wiki for the node and pool commands and you should see some examples. If that doesn't get you what you want, let me know exactly what you want accomplished when a match is found and I'll see what I can do to help you.
- webguy9_97931
Nimbostratus
I am looking to send the request to another host. For example: if www.foo.com\bar.html comes in I want to detect that pattern (*.\html) and proxy to www.anotherserver.com. - JRahm
Admin
when HTTP_REQUEST { switch -glob [HTTP::uri] { "*foo.html" { HTTP::redirect "www.anotherserver.com" } "/path/*" { HTTP:redirect "www.yetanotherserver.com" } "/dir1/*" - "/dir2/*" - "/dir3/*" { HTTP::redirect "www.yetagainanotherserver.com" } } }
- webguy9_97931
Nimbostratus
Thanks for the responses. This is a great forum! - As long as the backend servers are running both host applications and accept both domains then you can modify the Host header with
HTTP::header replace "Host" "www.host2.com"
HTTP::uri "/path2"
- Kevin_Holicky_5
Nimbostratus
Hi Joe... I have been working with webguy9. What needs to happen is everytime a bot or a particular URI pattern occurs in any HTTP_REQUEST, we need to proxy that request to a completely different domain (hosted at a 3rd party site) - If it's hosted at a 3rd party site, then unless it's contained in the default pool, simply replacing the headers won't do much aside from "tricking" the existing backend webserver that the request came to it with a different URI. If you need to send the client to another resource that is not in the BIG-IP's load balancing configuration, you are going to have to rely on a HTTP::redirect which sends a 302 response back to the browser with a Location header specifying that it should re-request the page from the new URL.
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