Forum Discussion
Greenberg
Nimbostratus
Mar 08, 2012iRule to Limit Connections from Source IP to Destination IP
Guys,
Novice to iRules brings himself before you.
I've been given a requirement to Limit the number of Connections from a number of Source Hosts to a Destination.
This ...
Greenberg
Nimbostratus
Mar 08, 2012Hi Aaron,
Thanks for your Assistance with this. Not my strongest Subject 😞
The Requirement has changed alittle.
They want to limit the maximum number of connections to a Virtual to 100.
If it's below 100 then allow but if it's above 100, only allow the Connection if an existing cookie is detected.
Here is the Rule I've created Offline
bigpipe rule '_Pi_throttle_tcp_connections {
when RULE_INIT {
set ::max_connections 100
set static ::active_connections 0
}
when HTTP_REQUEST {
if {$::active_connections > $::max_connections} then {
HTTP::respond 302 Location "Webpage.html" "Connection" "Close" "Cache-Control" "no-cache" "Pragma" "no-cache"
TCP::close
incr ::active_connections 1
elseif { [HTTP::cookie exists ] } then {
persist uie [HTTP::cookie ]
}
}
}
when CLIENT_CLOSED {
incr ::active_connections -1
}'
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