docs(roadmap): standardize rate limit configuration with constants
- Recommended defining rate limit thresholds as header constants in init.sh. - Updated documentation snippet to use GLOBAL_LIMIT_COUNT and GLOBAL_LIMIT_WINDOW variables. - Improved maintainability for future rate limit adjustments.
This commit is contained in:
parent
507e3a11a1
commit
0302b2e22a
@ -111,9 +111,14 @@ Keep the following APISIX plugin limits in `init/apisix-core/init.sh` for `test/
|
|||||||
| Auth routes `/v1/auth/*`, `/v1/users/*` | `limit-count` | `count: 12`, `time_window: 60` per `remote_addr` |
|
| Auth routes `/v1/auth/*`, `/v1/users/*` | `limit-count` | `count: 12`, `time_window: 60` per `remote_addr` |
|
||||||
| Global rule | `limit-count` | `count: 60`, `time_window: 60` per `remote_addr` |
|
| Global rule | `limit-count` | `count: 60`, `time_window: 60` per `remote_addr` |
|
||||||
|
|
||||||
Update the global rate limit block in `init/apisix-core/init.sh`:
|
Update the global rate limit block in `init/apisix-core/init.sh`. Define threshold constants at the script header to ensure consistency and ease of updates:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Define at the top of init.sh
|
||||||
|
GLOBAL_LIMIT_COUNT=60
|
||||||
|
GLOBAL_LIMIT_WINDOW=60
|
||||||
|
|
||||||
|
# ... later in the script ...
|
||||||
if [[ "$PROFILE" != "dev" ]]; then
|
if [[ "$PROFILE" != "dev" ]]; then
|
||||||
if [[ "$PROFILE" == "prod" ]]; then
|
if [[ "$PROFILE" == "prod" ]]; then
|
||||||
RATE_POLICY="redis"
|
RATE_POLICY="redis"
|
||||||
@ -125,7 +130,7 @@ if [[ "$PROFILE" != "dev" ]]; then
|
|||||||
|
|
||||||
call_api "global rate limit" -X PUT "$APISIX_ADMIN_URL/global_rules/1" \
|
call_api "global rate limit" -X PUT "$APISIX_ADMIN_URL/global_rules/1" \
|
||||||
-H "X-API-KEY: $API_KEY" -H "Content-Type: application/json" \
|
-H "X-API-KEY: $API_KEY" -H "Content-Type: application/json" \
|
||||||
-d '{"plugins":{"limit-count":{"count":60,"time_window":60,"key_type":"var","key":"remote_addr","rejected_code":429,"policy":"'"$RATE_POLICY"'","allow_degradation":true'"$RATE_REDIS"'}}}'
|
-d '{"plugins":{"limit-count":{"count":'"$GLOBAL_LIMIT_COUNT"',"time_window":'"$GLOBAL_LIMIT_WINDOW"',"key_type":"var","key":"remote_addr","rejected_code":429,"policy":"'"$RATE_POLICY"'","allow_degradation":true'"$RATE_REDIS"'}}}'
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user