Forum Discussion
Burak_ISIKSOY_1
Nimbostratus
Jul 18, 2014uri query limiting
hi,
I want to limit the queries to certain uri unfortunately I couldnt manage so far. Can someone point me what I am missing.Thanks
----------data group--------
query_limiter_uri;
Search.aspx
...
Kevin_Stewart
Employee
Jul 18, 2014Try with some additional logging:
when RULE_INIT {
set static::maxrate 2
set static::timespan 60
set static::respond_page { Too many requests. Try again later }
}
when HTTP_REQUEST {
if { ( [HTTP::method] eq "POST" ) and ( [class match [string tolower [HTTP::uri]] contains query_limiter_uri] ) } {
log local0. "POST to [HTTP::uri] and matches data group"
if { [class match [IP::client_addr] eq query_limiter_whitelist] } {
log local0. "Matches whitelist"
return
}
set cl_q [string tolower [HTTP::uri]]
set clid [IP::client_addr]:[IP::remote_addr]:[TCP::local_port]
set clid_q "${clid}:${cl_q}"
log local0. "clid_q = $clid_q"
if { [table lookup -subtable REQCOUNT $clid_q] eq "" } {
log local0. "new entry"
table set -subtable REQCOUNT $clid_q 1 $static::timespan
} elseif { [table lookup -subtable REQCOUNT $clid_q] > $static::maxrate } {
log local0. "-- $clid -- violation detected -- $cl_q -- exceeded number of requests --"
HTTP::respond 200 content $static::respond_page "Connection" "close"
} else {
log local0. "incrementing table entry"
table incr -subtable REQCOUNT $clid_q
}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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