I wanted to update / close this out. We were never able to get the irule to rewrite all of the HTTP_RESPONSE_DATA being passed back. well, correction. We were able to rewrite data up to the amount being collected w/ the HTTP::collect. When we set a length to the HTTP::collect of 1 MB we had issues w/ the pages not even displaying plus the latency introduced was not acceptable to the customer. They made changes to their application so that a simple http redirect irule and a simple source <=> target substitution stream profile were able to address the problem.
The final irule that this post was about is below. This seemed to provide the best mix of least delay and getting “most” of the data rewritten. The reason the app was changed is that none of the gifs would display properly to the customer since the applicaiton server in question wanted it’s server name in the the headers it was seeing and we never were able to completely rewrite the http_request data properly.
when HTTP_REQUEST {
switch [HTTP::header Host] {
nwte1jas7:8882 {
HTTP::header replace Host “nwte1jas7:8882”
}
nwte1jas7:8882 {
HTTP::header replace Host “nwte1jas6:8882”
}
}
}
when HTTP_RESPONSE {
if { [HTTP::header exists “Content-Length”] } {
set content_length [HTTP::header value “Content-Length”]
} else {
set content_length 5000
}
if { $content_length > 0 } {
HTTP::collect $content_length
}
if { [HTTP::status] starts_with “3” } {
switch [LB::server addr] {
10.0.19.50 {
HTTP::header replace Location [string map {nwte1jas7:8882 e1np.crocs.com} [HTTP::header Location]]
log local0.info “Replacing nwte1jas7:8882 with e1np.crocs.com in the header.”
}
10.0.19.42 {
HTTP::header replace Location [string map {nwte1jas6:8882 e1np.crocs.com} [HTTP::header Location]]
log local0.info “Replacing nwte1jas6:8882 with e1np.crocs.com in the header.”
}
}
}
}
when HTTP_RESPONSE_DATA {
log “running http_reponse_data event”
grab the response
switch [LB::server addr] {
10.0.19.50 {
regsub -all “nwte1jas7:8882” [HTTP::payload] “e1np.crocs.com” newpayload
log “Replacing nwtejas7:8882 with e1np.crocs.com in the payload.”
HTTP::payload replace 0 [HTTP::payload length] $newpayload
HTTP::release
}
10.0.19.42 {
regsub -all “nwte1jas6:8882” [HTTP::payload] “e1np.crocs.com” newpayload
log “Replacing nwtejas6:8882 with e1np.crocs.com in the payload.”
HTTP::payload replace 0 [HTTP::payload length] $newpayload
HTTP::release
}
}
}