Forum Discussion
hooleylist
May 09, 2008Cirrostratus
The post data parameter and parameter value wouldn't be accessible in an HTTP header. You'd need to collect the HTTP payload and then see if there is a sysid parameter. I think this will do what you're looking for. To use it, add a default pool to the VIP containing both nodes. If you run into issues, check the debug logging in /var/log/ltm. When you're done testing, you can comment out the log statements to save CPU/disk resources.
when HTTP_REQUEST {
Check if the request is a POST
if {[HTTP::method] eq "POST"}{
log local0. "[IP::client_addr]:[TCP::client_port]: POST request to [HTTP::uri]"
Collect the request data
if { [HTTP::header exists "Content-Length"] } {
Collect the content length as specified in the C-L header
set content_length [HTTP::header "Content-Length"]
} else {
Collect up to 1 Mib
set content_length 1000000000
}
log local0. "[IP::client_addr]:[TCP::client_port]: collecting $content_length bytes"
Trigger the collection of the request data if the content length isn't 0
if {$content_length}{
HTTP::collect $content_length
}
}
}
when HTTP_REQUEST_DATA {
log local0. "[IP::client_addr]:[TCP::client_port]: payload: [HTTP::payload]"
switch -glob [HTTP::payload] {
*sysid=1* {
Send the request to node 1
node 192.168.1.168 80
log local0. "[IP::client_addr]:[TCP::client_port]: found sysid=1, using node 1"
}
*sysid=2* {
Send the request to node 2
node 192.168.1.132 80
log local0. "[IP::client_addr]:[TCP::client_port]: found sysid=2, using node 2"
}
default {
Didn't find an expected sysid, do nothing. Use the default pool on the VIP.
log local0. "[IP::client_addr]:[TCP::client_port]: didn't find sysid"
}
}
}
Aaron