Forum Discussion
4 Replies
- MDolati_178990Nimbostratus
I want to make relation between cookie and number of session for example if i have a cookie called AAA this cookie just can establish 10 session or 10 get request.
- cjuniorNacreous
So, the cookie name/value will be provided by own server node or will get it from BIG-IP rule? In another words, who will control the cookie that BIG-IP should verify and count it? It's just a relevant information to my start.
- Satoshi_Toyosa1Employee
It depends.
If your requirement is "limit the number of accesses from the same source within a certain timeframe", you can use iRule table with an expiry timer to keep track of past sessions. For example, if the same user accesses the BIG-IP LTM 10 times within 100s, send back 50x response. You can determine the identity of the user by IP or cookie or any other unique values. The following sample shows IP address version. If you want to use cookie, you can use the value from
as the unique key.HTTP::cookie
If you are talking about "limit the currently running (connected) sessions in parallel", it would be a bit complicated: you need to decrement the count upon the CLIENT_CLOSE event. Better error handling may be needed too. HTTP sessions are usually short-lived, so you may not need to go this path (I think).
when RULE_INIT { set static::subtable "SatTest" set static::maxCount 10 } when HTTP_REQUEST { Default timeout is 180(s). The entry is deleted if not touched more than 'timeout'. set timeout 100 Default lifetime is 180(s). The entry is deleted after 'lifetime' from creation. set lifetime 100 set ip [IP::client_addr] set count [table lookup -notouch -subtable $static::subtable $ip] if {$count == ""} { log local0. "$ip does not exist. Created." table set -subtable $static::subtable $ip 1 $timeout $lifetime } elseif {$count > $static::maxCount} { log local0. "$ip exeeded the max count. $count > $static::maxCount. Call rejected." HTTP::respond 503 content "I am overloaded." return } else { log local0. "$ip $count + 1" table incr -subtable $static::subtable $ip } }
See also:
- MDolati_178990Nimbostratus
Dear cjunior, Cookies managed by BIGIP.