Forum Discussion
sgoodliff_83611
Nimbostratus
Oct 31, 2007connection limit on virtual server
Hello,
I would like to have a irule that sends back content via
HTTP::respond 200 content $html_content
When a virtual server has hit its connection limit. I've se...
hoolio
Cirrostratus
Oct 31, 2007I think something like this should work. It's untested though.
when RULE_INIT {
set ::active_connections 0
set ::max_connections 1000
set ::html_content "over limit"
set ::debug 1
}
when CLIENT_ACCEPTED {
Initialize a variable to track whether we're over the limit
and should send a response from the rule for this request
set over_limit 0
Check if we're over the maximum allowed connections
if {$::active_connections > $::max_connections } {
set over_limit 1
} else {
We're not over the max, so don't respond to the request
incr ::active_connections 1
}
}
when HTTP_REQUEST {
If we're over the limit for this connection, send a response
if {$over_limit}{
Send a response
HTTP::respond 200 content $::html_content
Close the connection
HTTP::close
Log a message to /var/log/ltm if debug is enabled
if {$::debug}{log local0. "Over limit (current/max: $::active_connections/$::max_connections). Sent response to [IP::client_addr]"}
}
}
when CLIENT_CLOSED {
A connection was closed, so decrement the global counter
incr ::active_connections -1
}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
