Forum Discussion
Greenberg
Mar 08, 2012Nimbostratus
iRule 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
Mar 12, 2012Nimbostratus
Hi Aaron,
It's Apache on a Linux Based Web Server.
This is another blast I had at the iRule:-
when RULE_INIT {
set static::max_connections_pi 2
set ::Inpicall =0
set static::active_connections_pi 0
}
when HTTP_REQUEST {
if { [HTTP::uri] contains "URI" } {
set inpicall=1;
incr ::active_connections_pi 1
if { not [HTTP::cookie exists "inpicheckout"] and $::active_connections_pi > $::max_connections_pi} {
HTTP::respond 302 Location "Website.html" "Connection" "Close" "Cache-Control" "no-cache" "Pragma" "no-cache" TCP::close
}
}
}
when HTTP_RESPONSE {
if $Inpicall==1
{ incr ::active_connections_pi -1
$Inpicall=0
}
}
when CLIENT_CLOSED { if $inpicall==1 { incr ::active_connections_pi -1 $Inpicall=0
}
}
Would this only max connections for traffic hitting the URI or all Connections hitting the Virtual Server?
Chris.
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