Here's the current draft for cloning to a single destination. We'll start functional and perf testing shortly. But I'd be happy to hear from anyone else about their experiences with it. I'd suggest using this in a test environment or at least a test virtual server. Just replace http_clone_pool with the name of the pool you want to copy requests to.
when CLIENT_ACCEPTED {
Open a new HSL connection if one is not available
set hsl [HSL::open -proto TCP -pool http_clone_pool]
log local0. "[IP::client_addr]:[TCP::client_port]: New hsl: $hsl"
}
when HTTP_REQUEST {
Insert an XFF header if one is not inserted already
So the client IP can be tracked for the duplicated traffic
HTTP::header insert X-Forwarded-For [IP::client_addr]
Check for POST requests
if {[HTTP::method] eq "POST"}{
Check for Content-Length between 1b and 1Mb
if { [HTTP::header Content-Length] >= 1 && [HTTP::header Content-Length] < 1048576 }{
HTTP::collect [HTTP::header Content-Length]
} elseif {[HTTP::header Content-Length] == 0}{
POST with 0 content-length, so just send the headers
HSL::send $hsl [HTTP::request]
log local0. "[IP::client_addr]:[TCP::client_port]: Sending [HTTP::request]"
}
} else {
Request with no payload, so send just the HTTP headers to the clone pool
HSL::send $hsl [HTTP::request]
log local0. "[IP::client_addr]:[TCP::client_port]: Sending [HTTP::request]"
}
}
when HTTP_REQUEST_DATA {
The parser does not allow HTTP::request in this event, but it works
set request_cmd "HTTP::request"
log local0. "[IP::client_addr]:[TCP::client_port]: Collected [HTTP::payload length] bytes,\
sending [expr {[string length [eval $request_cmd]] + [HTTP::payload length]}] bytes total"
HSL::send $hsl "[eval $request_cmd][HTTP::payload]"
}
Aaron