ghua / zim32-request-limit-bundle
使用此插件,您可以轻松限制对应用程序的请求
Requires
This package is not auto-updated.
Last update: 2024-09-28 14:32:50 UTC
README
概览
使用此插件,您可以轻松限制对应用程序的请求
安装
-
将 Zim32RequestLimitBundle 添加到您的 deps 文件
[Zim32RequestLimitBundle] git=git://github.com/zim32/Symfony2-RequestLimitBundle.git target=/bundles/Zim32/RequestLimitBundle Make /bin/vendors install
-
将 Zim32RequestLimitBundle 添加到您的 AppKernel
$bundles = array( ................. new Zim32\RequestLimitBundle\Zim32RequestLimitBundle(), );
-
将 Zim32 命名空间添加到您的 /app/autoload.php
$loader->registerNamespaces(array( ................ 'Zim32' => DIR.'/../vendor/bundles', ));
-
配置您的应用程序。例如
zim32_request_limit: rules: rule: path: /profile/ limit: 1 per: 60 ip: 192.168.1.2 some_foo_name: path: / limit: 10 per: 1
第一条规则将限制来自 IP 192.168.1.2 的 URL 以 /profile/ 开头每 60 秒只能请求一次
参考
- path (必需) - 应用规则的路由
- limit (必需) - 请求次数。对于立即拒绝,使用 '0' 限制
- per (必需) - 秒
- ip (可选) - 通过远程 IP 限制
您可以同时使用多个规则