Forum Discussion
Reroute traffic based on request content
This was an example, so you'll likely need to do some tweaking. For starters, add some logging statements to see what is returned from the findstr:
when HTTP_REQUEST {
if { [HTTP::header exists Content-Length] } {
Collect the payload and trigger the HTTP_REQUEST_DATA event
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
The HTTP request payload is buffered and accessible here
N ow use string functions to get the username from the request payload
set username [findstr [HTTP::payload] "" 10 ""]
log local0. "username = $username"
switch $username {
"bob" { pool bob_pool }
"alice" { pool alice_pool }
"eve" { pool eve_pool }
"oscar" { pool oscar_pool }
default { pool default_pool }
}
}
Now test that and either look at LTM logs in the management GUI, or better, open up an SSH session to the BIG-IP and tail the LTM log:
tail -f /var/log/ltm
You'll be looking for a log statement like this:
username = [something]
If the username value is empty, then you know the findstr isn't returning something and you need to modify the search. If it is returning something, then perhaps the switch isn't right. Start there and let us know what you find.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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