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 handling requests for the old. They are phasing in this change gradually. I believe they need an iRule that detects a client connection, and 1) inspects tcp payload for a specific string (call to new service), and if found, redirects that traffic to the new service, url B) if upon inspection, the payload does not contain that string, redirect to old service, url A, which is an existing pool, providing the original service. Will something like the below work?
when CLIENT_ACCEPTED {
set port [80]
if { [TCP::local_port] == $port } {
TCP::collect 300
}
}
when CLIENT_DATA {
if { [TCP::payload] contains ""} {
log "Request For New XML Service Found. Sending to ASPX page."
HTTP::redirect urlB
}else {
log "Request Was for Old XML Service. Sending to Default xml Pool."
pool xml_pool
} else
}client_data
- Is this data going over HTTP? If so, do you have an HTTP profile associated with your virtual?
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 } }
- dc_18986Historic F5 AccountYes, it helps indeed. I'm virtually 100% positive that this will be done over HTTP. I think your suggestions will make an excellent starting point. I'm curious, can you point me to an example on how to do this if I were working at a TCP data level? For sure, it'll come up some time.
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