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
...
Burak_ISIKSOY_1
Nimbostratus
Jul 18, 2014So instead of trying to figure whats wrong I am trying an other code i have found. Issue this time is when try to respond with a message stating that too many request webpage complaining me that "An HTTP Content-Type header is required for SOAP messaging and none was found."
Well since I suck at coding I would be glad if someone can show me what I am doing wrong
when RULE_INIT {
set static::maxRate 5
set static::windowSecs 20
set static::timeout 30
}
when HTTP_REQUEST {
This I-Rule limits "POST" requests, if you want to limit GETs instead, replace
"POST" with "GET" in if statement below.
If you want to limit all types or requests, remove this "if" statement below as well as its
Corresponding curly bracket '\}' on or around line 67 clearly maked with a comment.
if { [HTTP::method] eq "POST" } {
set myUserID "user"
Uncomment the block below if you want to throttle requests for each user individually.
Also remove the line directly above this comment which sets the value of "myUserID"
if {[HTTP::header exists FooUser]} {
set myUserID [HTTP::header FooUser]
} else {
HTTP::respond 401
return
}
set currentTime [clock seconds]
set windowStart [expr {$currentTime - $static::windowSecs}]
set postCount 0
PH stands for posthistory, a term from the original irule.
log -noname local0. "Table Keys [table keys -subtable 'PH:${myUserID}.${AES_key}']"
foreach { requestTime } [table keys -subtable "PH:${myUserID}"] {
count POSTs with start time > $windowStart, delete the rest
if { $requestTime > $windowStart } {
incr postCount 1
} else {
table delete -subtable "PH:${myUserID}" $requestTime
}
}
if { $postCount < $static::maxRate } {
add new record to array w/myUserID.rand + currentTime
set requestID "PH:${myUserID}"
table set -subtable $requestID $currentTime "ignored" $static::timeout
} else {
log -noname local0. "POST Rejected: current postCount for ${myUserID}: $postCount"
HTTP::respond 200 content {
Too many requests
Too many requests, please try again later.
}
}
Remove the curly bracket "\}" on the line below if you removed the 'if' statement above.
}
}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