Forum Discussion
HTTP connection limit + cookie insert from BigIP
http://devcentral.f5.com/wiki/default.aspx/iRules/HTTPSessionLimit.html
but I am not having any luck. Does anyone know how to add some additional logging, perhaps each time the rule is hit it logs the current active connections or when it checks for the cookie? I am using cookie insert generating the cookie from the LTM, I assume that this rule will work with this persistence as well?
Appreciate any feedback.
-L
- hoolio
Cirrostratus
What are you actually seeing happen? Persistence shouldn't have any impact on the rule, as it's not specifying which pool members a request goes to.rule HTTP_session_limit { when RULE_INIT { set ::debug 1 set ::total_active_clients 0 set ::max_active_clients 100 log local0. "rule session_limit initialized: total/max: $::total_active_clients/$::max_active_clients" } when HTTP_REQUEST { if {$::debug}{ set uri [HTTP::uri]} ; test cookie presence if {[HTTP::cookie exists "ClientID"]} { set need_cookie 0 set client_id [HTTP::cookie "ClientID"] if {$::debug}{ log local0. "client [IP::client_addr] with cookie $client_id -> $uri, count: $::total_active_clients"} ; if cookie not present & connection limit not reached, set up client_id } else { if {$::total_active_clients < $::max_active_clients} { set need_cookie 1 set client_id [format "%08d" [expr { int(100000000 * rand()) }]] incr ::total_active_clients if {$::debug}{ log local0. "client [IP::client_addr] with no cookie, under connection limit -> $uri, count: $::total_active_clients"} ; otherwise redirect } else { if {$::debug}{ log local0. "client [IP::client_addr] with no cookie over limit, redirected -> $uri, count: $::total_active_clients"} HTTP::redirect "http://sorry.domain.com/" return } } } when HTTP_RESPONSE { ; insert cookie if needed if {$need_cookie == 1} { if {$::debug}{ log local0. "client [IP::client_addr] inserting cookie: $client_id"} HTTP::cookie insert name "ClientID" value $client_id } } when CLIENT_CLOSED { ; decrement current connection counter for this client_id if {$::total_active_clients > 0} { incr ::total_active_clients -1 if {$::debug}{ log local0. "client [IP::client_addr] closing connection with cookie $client_id -> $uri, count: $::total_active_clients"} } } }
- Leslie_South_55
Nimbostratus
Thanks for the debug lines, I was playing around and got real close, bu you closed the loop for me.Sep 6 15:02:11 tmm tmm[22188]: 01220001:3: TCL error: Rule rule_http-session-limit-3 - Operation not supported. Multiple redirect/respond invocations not allowed (line 1) invoked from within "HTTP::redirect "http://sorry.domain.com/""
- Leslie_South_55
Nimbostratus
here is some more debug info for the complete page load and close. I have my max set to 15, it appears that my session is getting several cookies, sometimes it lets me in other times it redirectsHTTP_REQUEST>: client 10.2.47.82 with no cookie, under connection limit -> /, count: 11
- Leslie_South_55
Nimbostratus
Does anyone have any thoughts here...from what the log gives me, it looks like there are multiple cookies being issued to a single client. The log was generated by a single session. It makes sense that the logic in the rule is looking at all the cookies, but I need to be able to limit the cookie generation, 1 per client browser....please help if you can, this functionality has become more necessary with our production site. - hoolio
Cirrostratus
It looks like the client is making multiple requests before getting back the initial response containing the set-cookie header. This could either be pipelined on the same TCP connection or separate TCP connections.if {[HTTP::cookie exists "ClientID"] or [HTTP::request_num] > 1 } {
- Leslie_South_55
Nimbostratus
Are the requests going through a proxy server, or is this truly one client making requests?
if {[HTTP::cookie exists "ClientID"] or [HTTP::request_num] > 1}
- hoolio
Cirrostratus
Are you seeing the requests redirected, or are you getting a TCL error? - Leslie_South_55
Nimbostratus
I added some additional logging to track client request number and server response number, and there are multiple requests from the same client - Leslie_South_55
Nimbostratus
I see that the client port is changing for the pages where the images don't load - Leslie_South_55
Nimbostratus
Any ideas on the multiple client ports/client connections?
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