Forum Discussion
dc_18986
Aug 30, 2007Historic F5 Account
My 1st iRule - How can I improve this?
Hello all,
Below is my 1st attempt at an iRule. A client of ours is replacing a Java servlet with an ASPX page. They want to the ability to process requests for the new service, while still...
Aug 30, 2007
Is this data going over HTTP? If so, do you have an HTTP profile associated with your virtual?
The reason why I ask is that the HTTP::redirect command is only available in the HTTP_REQUEST and HTTP_REQUEST_DATA events, not the CLIENT_DATA event. If you are working at the TCP data level (CLIENT_DATA, etc), you'll need to form your own HTTP 302 response (including correct HTTP response headers/etc), that the HTTP::respond command does for you, and send it back to the client with the TCP::respond command. That's going to be a bit tricky, but it's possible.
If you do have a HTTP profile, then things are much easier for you. Something like this should work:
when HTTP_REQUEST {
if { [TCP::local_port] == 80 } {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
if { [HTTP::payload] contains "" } {
log local0. "Request for new XML Service Found. Sending ASPX page."
HTTP::redirect "http://otherdomain/otheruri"
} else {
log local0. "Request was for Old XML Service. Sending to Default xml Pool."
pool xml_pool
}
}Better yet, I'd assign "xml_pool" as the default pool for the virtual and you can leave the else clause out altogether.
Hope this helps...
-Joe
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