Forum Discussion
ahmetnuman
Nov 14, 2020Nimbostratus
Limit HTTP Request on LTM
Hello , I want to limit total number of HTTP request on our web application uri (like /test/test1). Is there any irule to accomplish this ? Thank you very much
ahmetnuman
Nov 15, 2020Nimbostratus
Hello Dario thank you very much for reply,
I solved my problem via using following irule, it works very well, this i rule briefly count the coming http request on the vip ip if the uri's are /bla/blaservice or /bla/blaservices, then if maximum rate is reached within 2 sec, then bigip response http 2oo status code with blank pages.
when RULE_INIT {
set static::maxRate 4000
set static::windowSecs 2
}
when HTTP_REQUEST {
if { [HTTP::uri] == "/blablaservice" or [HTTP::uri] == "/blablaservices/"} {
# set variables
set limiter [string tolower [HTTP::uri]]
set vip_limitervar [IP::local_addr]:$limiter
set get_count [table key -count -subtable $vip_limitervar]
# main condition
if { $get_count < $static::maxRate } {
incr get_count 1
table set -subtable $vip_limitervar $get_count $vip_limitervar indefinite $static::windowSecs
} else {
#log local0. "$vip_limitervar has exceeded the number of requests allowed."
HTTP::respond 200 content ""
return
}
}
}
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