Forum Discussion
David_X_20743
Nimbostratus
May 09, 2008LB method setup and post redirect
Hi
I am new to the F5 iRules. I am currently setting up a set of of iRules for a customer and get really lost. So any suggestion will be really appreciated.
The customer...
hoolio
Cirrostratus
May 09, 2008The 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
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
