docs: update rate limiting

This commit is contained in:
Jonas Kaninda
2024-11-25 08:38:03 +01:00
parent 42292bb53d
commit f0f5dea2a3
2 changed files with 26 additions and 4 deletions

View File

@@ -10,12 +10,34 @@ nav_order: 6
The RateLimit middleware ensures that services will receive a fair number of requests, and allows one to define what fair is. The RateLimit middleware ensures that services will receive a fair number of requests, and allows one to define what fair is.
Example of global rateLimit middleware Example of rate limiting middleware
```yaml
middlewares:
- name: rate-limit
type: ratelimit #or rateLimit
paths:
- /*
rule:
unit: minute # or hour
requestsPerUnit: 10
```
Example of route rate limiting middleware
```yaml
version: 0.1.7
gateway:
routes:
- name: Example
rateLimit: 60 # peer minute
```
Example of global rate limiting middleware
```yaml ```yaml
version: 0.1.7 version: 0.1.7
gateway: gateway:
# Proxy rate limit, it's In-Memory IP based
rateLimit: 60 # peer minute rateLimit: 60 # peer minute
routes: routes:
- name: Example - name: Example

View File

@@ -42,7 +42,7 @@ type Route struct {
HealthCheck RouteHealthCheck `yaml:"healthCheck"` HealthCheck RouteHealthCheck `yaml:"healthCheck"`
// Cors contains the route cors headers // Cors contains the route cors headers
Cors Cors `yaml:"cors"` Cors Cors `yaml:"cors"`
RateLimit int `yaml:"rateLimit"` RateLimit int `yaml:"rateLimit,omitempty"`
// DisableHostFording Disable X-forwarded header. // DisableHostFording Disable X-forwarded header.
// //
// [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ] // [X-Forwarded-Host, X-Forwarded-For, Host, Scheme ]