17/10
2017
Wallogit.com
2017 © Pedro Peláez
Allow guest clients to be rate limited, using their IP as the identifier.
, (*1)
Allow guest clients to be rate limited, using their IP as the identifier., (*2)
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require ethercreative/yii2-ip-ratelimiter "1.*"
or add, (*5)
"ethercreative/yii2-ip-ratelimiter": "1.*"
to the require section of your composer.json file., (*6)
Modify the bahavior method of the controller you want to rate limit, (*7)
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['rateLimiter'] = [
// Use class
'class' => \ethercreative\ratelimiter\RateLimiter::className(),
// The maximum number of allowed requests
'rateLimit' => 100,
// The time period for the rates to apply to
'timePeriod' => 600,
// Separate rate limiting for guests and authenticated users
// Defaults to true
// - false: use one set of rates, whether you are authenticated or not
// - true: use separate ratesfor guests and authenticated users
'separateRates' => false,
// Whether to return HTTP headers containing the current rate limiting information
'enableRateLimitHeaders' => false,
];
return $behaviors;
}