Forum Discussion
____177053
Sep 20, 2017Cirrus
How to limit http request rate
I wants to limit http request rate for some of URIs such as "/a" "/b" "/c",and I wrote one but it didn't work:
when HTTP_REQUEST {
set start_time [clock seconds]
set reqs_sec 0
if { [HTTP::reque...
- Sep 20, 2017
This one works! when HTTP_REQUEST {
set lrqst 10 set ltime 10 set rtime 5 if {[table lookup -notouch -subtable "blacklist" [HTTP::uri]] != "" }{ reject log local0.warn "reject" } elseif { [table lookup -notouch -subtable "clientxdlist" [HTTP::uri]] == "" }{ table set -subtable "clientxdlist" [HTTP::uri] 1 indefinite $ltime } elseif { [table lookup -notouch -subtable "clientxdlist" [HTTP::uri]] < $lrqst}{ table incr -subtable "clientxdlist" [HTTP::uri] } else { table set -subtable "blacklist" [HTTP::uri] 1 indefinite $rtime }
}
____177053
Sep 20, 2017Cirrus
This one works! when HTTP_REQUEST {
set lrqst 10
set ltime 10
set rtime 5
if {[table lookup -notouch -subtable "blacklist" [HTTP::uri]] != "" }{
reject
log local0.warn "reject"
}
elseif { [table lookup -notouch -subtable "clientxdlist" [HTTP::uri]] == "" }{
table set -subtable "clientxdlist" [HTTP::uri] 1 indefinite $ltime
}
elseif { [table lookup -notouch -subtable "clientxdlist" [HTTP::uri]] < $lrqst}{
table incr -subtable "clientxdlist" [HTTP::uri]
}
else {
table set -subtable "blacklist" [HTTP::uri] 1 indefinite $rtime
}
}
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