Forum Discussion
AdamFoot_1451
Nimbostratus
May 16, 2008Cookie and URI Decisions
Hi all,
Could someone just check this over for me please.The goal is to add some
persistence based on version cookie,so we can direct version specific traffic to specific pools.
In addition we also need to direct traffic for a specific URI out of a different SNAT,so it can be checked by a passive AV proxy.
Requirements are:
1. No cookie , so the request goes to the default pool.
2. Version cookie exists and matches the URI so send out of a different SNAT to the AV gateway pool.
3. There is a version cookie but no matching URI.
I've put together the following which the LTM accepts.In addition to it working,I need to make it as efficient as possible.Is this the best way to do this?
when HTTP_REQUEST {
Set deault pool
set defpool [LB::server pool]
Extract the Cookie
set ID [findstr [HTTP::cookie "CookieX"] "Cookie" 10 ";"]
Extract the URI
set my_uri [string tolower [HTTP::uri]]
Log the values
log local0. "ID is $ID default pool is $defpool"
If no Cookie exists
if {($ID equals "")} {
log local0. "sending user to pool $defpool"
pool $defpool
If there is a cookie and a URI of /AttachmentShare/Upload.aspx
}
elseif {[$my_uri contains "/AttachmentShare/Upload.aspx"] and [ $ID not equals ""] } {
log local0. "URI contains $my_uri sending user to pool pool$ID"
[pool AVpool$ID] and [snatpool SNAT_$ID]
}
else {
If there is a cookie but no URI
pool pool$ID
}
}
Thanks in advance,
Adam
- Andy_Herrman_22
Nimbostratus
Looks good to me. The only efficiency things I can think of would be to turn off the logs when you actually deploy this (otherwise you could fill up the logs pretty fast), and use 'starts_with' instead of 'contains' in your findstr call (assuming that path you're looking for is the absolute path. If there could be other path elements before it then 'starts_with' wouldn't work right). - AdamFoot_1451
Nimbostratus
Hi ,still working this through. Made it more efficient and removed the cookie checks but I'm now getting a syntax error and can't work out where the problem is. - hoolio
Cirrostratus
Hi Adam,when CLIENT_ACCEPTED { Save the name of the default pool of the VIP set default_pool [LB::server pool] } when HTTP_REQUEST { log local0.info "URL is [HTTP::host][HTTP::uri], VIP is [IP::local_addr]:[TCP::local_port] URI is [HTTP::uri]" If Attachment URI exists if {[string tolower [HTTP::path]] ends_with "/attachmentshare/upload.aspx"}{ snatpool SNAT_10.10.10.10 pool AVG1 log local0. "sending user to attachment pool AVG1 SNAT_20.146.203.122" } else { log local0.info "sending user to default pool $default_pool" pool default_pool } }
- AdamFoot_1451
Nimbostratus
Hi 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