Add Redis rate limiter
This commit is contained in:
parent
c166a41c99
commit
550d96ea67
26 changed files with 2268 additions and 69 deletions
|
@ -496,3 +496,718 @@ http:
|
|||
[http.middlewares.test-ratelimit.rateLimit.sourceCriterion]
|
||||
requestHost = true
|
||||
```
|
||||
|
||||
### `redis`
|
||||
|
||||
Enables distributed rate limit using `redis` to store the tokens.
|
||||
If not set, Traefik's in-memory storage is used by default.
|
||||
|
||||
#### `redis.endpoints`
|
||||
|
||||
_Required, Default="127.0.0.1:6379"_
|
||||
|
||||
Defines how to connect to the Redis server.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.endpoints=127.0.0.1:6379"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
endpoints:
|
||||
- "127.0.0.1:6379"
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.endpoints=127.0.0.1:6379"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
endpoints:
|
||||
- "127.0.0.1:6379"
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
endpoints = ["127.0.0.1:6379"]
|
||||
```
|
||||
|
||||
#### `redis.username`
|
||||
|
||||
_Optional, Default=""_
|
||||
|
||||
Defines the username used to authenticate with the Redis server.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.username=user"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
secret: mysecret
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mysecret
|
||||
namespace: default
|
||||
|
||||
data:
|
||||
username: dXNlcm5hbWU=
|
||||
password: cGFzc3dvcmQ=
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.username=user"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
username: user
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
username = "user"
|
||||
```
|
||||
|
||||
#### `redis.password`
|
||||
|
||||
_Optional, Default=""_
|
||||
|
||||
Defines the password to authenticate against the Redis server.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.password=password"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
secret: mysecret
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mysecret
|
||||
namespace: default
|
||||
|
||||
data:
|
||||
username: dXNlcm5hbWU=
|
||||
password: cGFzc3dvcmQ=
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.password=password"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
password: password
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
password = "password"
|
||||
```
|
||||
|
||||
#### `redis.db`
|
||||
|
||||
_Optional, Default=0_
|
||||
|
||||
Defines the database to select after connecting to the Redis.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.db=0"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
db: 0
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.db=0"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
db: 0
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
db = 0
|
||||
```
|
||||
|
||||
#### `redis.tls`
|
||||
|
||||
Same as this [config](https://doc.traefik.io/traefik/providers/redis/#tls)
|
||||
|
||||
_Optional_
|
||||
|
||||
Defines the TLS configuration used for the secure connection to Redis.
|
||||
|
||||
##### `redis.tls.ca`
|
||||
|
||||
_Optional_
|
||||
|
||||
`ca` is the path to the certificate authority used for the secure connection to Redis,
|
||||
it defaults to the system bundle.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.ca=path/to/ca.crt"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
caSecret: mycasercret
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mycasercret
|
||||
namespace: default
|
||||
|
||||
data:
|
||||
# Must contain a certificate under either a `tls.ca` or a `ca.crt` key.
|
||||
tls.ca: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.ca=path/to/ca.crt"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
ca: path/to/ca.crt
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[providers.redis.tls]
|
||||
ca = "path/to/ca.crt"
|
||||
```
|
||||
|
||||
##### `redis.tls.cert`
|
||||
|
||||
_Optional_
|
||||
|
||||
`cert` is the path to the public certificate used for the secure connection to Redis.
|
||||
When this option is set, the `key` option is required.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.cert=path/to/foo.cert"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.key=path/to/foo.key"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
certSecret: mytlscert
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mytlscert
|
||||
namespace: default
|
||||
|
||||
data:
|
||||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
|
||||
tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.cert=path/to/foo.cert"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.key=path/to/foo.key"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
redis:
|
||||
tls:
|
||||
cert: path/to/foo.cert
|
||||
key: path/to/foo.key
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis.tls]
|
||||
cert = "path/to/foo.cert"
|
||||
key = "path/to/foo.key"
|
||||
```
|
||||
|
||||
##### `redis.tls.key`
|
||||
|
||||
_Optional_
|
||||
|
||||
`key` is the path to the private key used for the secure connection to Redis.
|
||||
When this option is set, the `cert` option is required.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.cert=path/to/foo.cert"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.key=path/to/foo.key"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
certSecret: mytlscert
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: mytlscert
|
||||
namespace: default
|
||||
|
||||
data:
|
||||
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
|
||||
tls.key: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0=
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.cert=path/to/foo.cert"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.key=path/to/foo.key"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
redis:
|
||||
tls:
|
||||
cert: path/to/foo.cert
|
||||
key: path/to/foo.key
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis.tls]
|
||||
cert = "path/to/foo.cert"
|
||||
key = "path/to/foo.key"
|
||||
```
|
||||
|
||||
##### `redis.tls.insecureSkipVerify`
|
||||
|
||||
_Optional, Default=false_
|
||||
|
||||
If `insecureSkipVerify` is `true`, the TLS connection to Redis accepts any certificate presented by the server regardless of the hostnames it covers.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.insecureSkipVerify=true"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
insecureSkipVerify: true
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.tls.insecureSkipVerify=true"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
tls:
|
||||
insecureSkipVerify: true
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis.tls]
|
||||
insecureSkipVerify = true
|
||||
```
|
||||
|
||||
#### `redis.poolSize`
|
||||
|
||||
_Optional, Default=0_
|
||||
|
||||
Defines the base number of socket connections.
|
||||
|
||||
If there are not enough connections in the pool, new connections will be allocated beyond `redis.poolSize`.
|
||||
You can limit this using `redis.maxActiveConns`.
|
||||
|
||||
Zero means 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.poolSize=42"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
poolSize: 42
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.poolSize=42"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
poolSize: 42
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
poolSize = 42
|
||||
```
|
||||
|
||||
#### `redis.minIdleConns`
|
||||
|
||||
_Optional, Default=0_
|
||||
|
||||
Defines the minimum number of idle connections, which is useful when establishing new connections is slow.
|
||||
Zero means that idle connections are not closed.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.minIdleConns=42"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
minIdleConns: 42
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.minIdleConns=42"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
minIdleConns: 42
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
minIdleConns = 42
|
||||
```
|
||||
|
||||
#### `redis.maxActiveConns`
|
||||
|
||||
_Optional, Default=0_
|
||||
|
||||
Defines the maximum number of connections the pool can allocate at a given time.
|
||||
Zero means no limit.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.maxActiveConns=42"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
maxActiveConns: 42
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.maxActiveConns=42"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
maxActiveConns: 42
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
maxActiveConns = 42
|
||||
```
|
||||
|
||||
#### `redis.readTimeout`
|
||||
|
||||
_Optional, Default=3s_
|
||||
|
||||
Defines the timeout for socket reads.
|
||||
If reached, commands will fail with a timeout instead of blocking.
|
||||
Zero means no timeout.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.readTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
readTimeout: 42s
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.readTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
readTimeout: 42s
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
readTimeout = "42s"
|
||||
```
|
||||
|
||||
#### `redis.writeTimeout`
|
||||
|
||||
_Optional, Default=3s_
|
||||
|
||||
Defines the timeout for socket writes.
|
||||
If reached, commands will fail with a timeout instead of blocking.
|
||||
Zero means no timeout.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.writeTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
writeTimeout: 42s
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.writeTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
writeTimeout: 42s
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
writeTimeout = "42s"
|
||||
```
|
||||
|
||||
#### `redis.dialTimeout`
|
||||
|
||||
_Optional, Default=5s_
|
||||
|
||||
Defines the dial timeout for establishing new connections.
|
||||
Zero means no timeout.
|
||||
|
||||
```yaml tab="Docker & Swarm"
|
||||
labels:
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.dialTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="Kubernetes"
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: test-ratelimit
|
||||
spec:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
dialTimeout: 42s
|
||||
```
|
||||
|
||||
```yaml tab="Consul Catalog"
|
||||
- "traefik.http.middlewares.test-ratelimit.ratelimit.redis.dialTimeout=42s"
|
||||
```
|
||||
|
||||
```yaml tab="File (YAML)"
|
||||
http:
|
||||
middlewares:
|
||||
test-ratelimit:
|
||||
rateLimit:
|
||||
# ...
|
||||
redis:
|
||||
dialTimeout: 42s
|
||||
```
|
||||
|
||||
```toml tab="File (TOML)"
|
||||
[http.middlewares]
|
||||
[http.middlewares.test-ratelimit.rateLimit]
|
||||
[http.middlewares.test-ratelimit.rateLimit.redis]
|
||||
dialTimeout = "42s"
|
||||
```
|
||||
|
|
|
@ -132,6 +132,20 @@
|
|||
- "traefik.http.middlewares.middleware18.ratelimit.average=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.burst=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.period=42s"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.db=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.dialtimeout=42s"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.endpoints=foobar, foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.maxactiveconns=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.minidleconns=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.password=foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.poolsize=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.readtimeout=42s"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.tls.ca=foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.tls.cert=foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.tls.insecureskipverify=true"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.tls.key=foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.username=foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.redis.writetimeout=42s"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.sourcecriterion.ipstrategy.depth=42"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.sourcecriterion.ipstrategy.excludedips=foobar, foobar"
|
||||
- "traefik.http.middlewares.middleware18.ratelimit.sourcecriterion.ipstrategy.ipv6subnet=42"
|
||||
|
|
|
@ -311,6 +311,22 @@
|
|||
depth = 42
|
||||
excludedIPs = ["foobar", "foobar"]
|
||||
ipv6Subnet = 42
|
||||
[http.middlewares.Middleware18.rateLimit.redis]
|
||||
endpoints = ["foobar", "foobar"]
|
||||
username = "foobar"
|
||||
password = "foobar"
|
||||
db = 42
|
||||
poolSize = 42
|
||||
minIdleConns = 42
|
||||
maxActiveConns = 42
|
||||
readTimeout = "42s"
|
||||
writeTimeout = "42s"
|
||||
dialTimeout = "42s"
|
||||
[http.middlewares.Middleware18.rateLimit.redis.tls]
|
||||
ca = "foobar"
|
||||
cert = "foobar"
|
||||
key = "foobar"
|
||||
insecureSkipVerify = true
|
||||
[http.middlewares.Middleware19]
|
||||
[http.middlewares.Middleware19.redirectRegex]
|
||||
regex = "foobar"
|
||||
|
|
|
@ -360,6 +360,24 @@ http:
|
|||
ipv6Subnet: 42
|
||||
requestHeaderName: foobar
|
||||
requestHost: true
|
||||
redis:
|
||||
endpoints:
|
||||
- foobar
|
||||
- foobar
|
||||
tls:
|
||||
ca: foobar
|
||||
cert: foobar
|
||||
key: foobar
|
||||
insecureSkipVerify: true
|
||||
username: foobar
|
||||
password: foobar
|
||||
db: 42
|
||||
poolSize: 42
|
||||
minIdleConns: 42
|
||||
maxActiveConns: 42
|
||||
readTimeout: 42s
|
||||
writeTimeout: 42s
|
||||
dialTimeout: 42s
|
||||
Middleware19:
|
||||
redirectRegex:
|
||||
regex: foobar
|
||||
|
|
|
@ -1790,6 +1790,90 @@ spec:
|
|||
Period, in combination with Average, defines the actual maximum rate, such as:
|
||||
r = Average / Period. It defaults to a second.
|
||||
x-kubernetes-int-or-string: true
|
||||
redis:
|
||||
description: Redis hold the configs of Redis as bucket in rate
|
||||
limiter.
|
||||
properties:
|
||||
db:
|
||||
description: DB defines the Redis database that will be selected
|
||||
after connecting to the server.
|
||||
type: integer
|
||||
dialTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
DialTimeout sets the timeout for establishing new connections.
|
||||
Default value is 5 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
endpoints:
|
||||
description: |-
|
||||
Endpoints contains either a single address or a seed list of host:port addresses.
|
||||
Default value is ["localhost:6379"].
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
maxActiveConns:
|
||||
description: |-
|
||||
MaxActiveConns defines the maximum number of connections allocated by the pool at a given time.
|
||||
Default value is 0, meaning there is no limit.
|
||||
type: integer
|
||||
minIdleConns:
|
||||
description: |-
|
||||
MinIdleConns defines the minimum number of idle connections.
|
||||
Default value is 0, and idle connections are not closed by default.
|
||||
type: integer
|
||||
poolSize:
|
||||
description: |-
|
||||
PoolSize defines the initial number of socket connections.
|
||||
If the pool runs out of available connections, additional ones will be created beyond PoolSize.
|
||||
This can be limited using MaxActiveConns.
|
||||
// Default value is 0, meaning 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||
type: integer
|
||||
readTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
ReadTimeout defines the timeout for socket read operations.
|
||||
Default value is 3 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
secret:
|
||||
description: Secret defines the name of the referenced Kubernetes
|
||||
Secret containing Redis credentials.
|
||||
type: string
|
||||
tls:
|
||||
description: |-
|
||||
TLS defines TLS-specific configurations, including the CA, certificate, and key,
|
||||
which can be provided as a file path or file content.
|
||||
properties:
|
||||
caSecret:
|
||||
description: |-
|
||||
CASecret is the name of the referenced Kubernetes Secret containing the CA to validate the server certificate.
|
||||
The CA certificate is extracted from key `tls.ca` or `ca.crt`.
|
||||
type: string
|
||||
certSecret:
|
||||
description: |-
|
||||
CertSecret is the name of the referenced Kubernetes Secret containing the client certificate.
|
||||
The client certificate is extracted from the keys `tls.crt` and `tls.key`.
|
||||
type: string
|
||||
insecureSkipVerify:
|
||||
description: InsecureSkipVerify defines whether the server
|
||||
certificates should be validated.
|
||||
type: boolean
|
||||
type: object
|
||||
writeTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
WriteTimeout defines the timeout for socket write operations.
|
||||
Default value is 3 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
type: object
|
||||
sourceCriterion:
|
||||
description: |-
|
||||
SourceCriterion defines what criterion is used to group requests as originating from a common source.
|
||||
|
|
|
@ -153,6 +153,21 @@ THIS FILE MUST NOT BE EDITED BY HAND
|
|||
| `traefik/http/middlewares/Middleware18/rateLimit/average` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/burst` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/period` | `42s` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/db` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/dialTimeout` | `42s` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/endpoints/0` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/endpoints/1` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/maxActiveConns` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/minIdleConns` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/password` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/poolSize` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/readTimeout` | `42s` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/tls/ca` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/tls/cert` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/tls/insecureSkipVerify` | `true` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/tls/key` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/username` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/redis/writeTimeout` | `42s` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/sourceCriterion/ipStrategy/depth` | `42` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/sourceCriterion/ipStrategy/excludedIPs/0` | `foobar` |
|
||||
| `traefik/http/middlewares/Middleware18/rateLimit/sourceCriterion/ipStrategy/excludedIPs/1` | `foobar` |
|
||||
|
|
|
@ -1027,6 +1027,90 @@ spec:
|
|||
Period, in combination with Average, defines the actual maximum rate, such as:
|
||||
r = Average / Period. It defaults to a second.
|
||||
x-kubernetes-int-or-string: true
|
||||
redis:
|
||||
description: Redis hold the configs of Redis as bucket in rate
|
||||
limiter.
|
||||
properties:
|
||||
db:
|
||||
description: DB defines the Redis database that will be selected
|
||||
after connecting to the server.
|
||||
type: integer
|
||||
dialTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
DialTimeout sets the timeout for establishing new connections.
|
||||
Default value is 5 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
endpoints:
|
||||
description: |-
|
||||
Endpoints contains either a single address or a seed list of host:port addresses.
|
||||
Default value is ["localhost:6379"].
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
maxActiveConns:
|
||||
description: |-
|
||||
MaxActiveConns defines the maximum number of connections allocated by the pool at a given time.
|
||||
Default value is 0, meaning there is no limit.
|
||||
type: integer
|
||||
minIdleConns:
|
||||
description: |-
|
||||
MinIdleConns defines the minimum number of idle connections.
|
||||
Default value is 0, and idle connections are not closed by default.
|
||||
type: integer
|
||||
poolSize:
|
||||
description: |-
|
||||
PoolSize defines the initial number of socket connections.
|
||||
If the pool runs out of available connections, additional ones will be created beyond PoolSize.
|
||||
This can be limited using MaxActiveConns.
|
||||
// Default value is 0, meaning 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
|
||||
type: integer
|
||||
readTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
ReadTimeout defines the timeout for socket read operations.
|
||||
Default value is 3 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
secret:
|
||||
description: Secret defines the name of the referenced Kubernetes
|
||||
Secret containing Redis credentials.
|
||||
type: string
|
||||
tls:
|
||||
description: |-
|
||||
TLS defines TLS-specific configurations, including the CA, certificate, and key,
|
||||
which can be provided as a file path or file content.
|
||||
properties:
|
||||
caSecret:
|
||||
description: |-
|
||||
CASecret is the name of the referenced Kubernetes Secret containing the CA to validate the server certificate.
|
||||
The CA certificate is extracted from key `tls.ca` or `ca.crt`.
|
||||
type: string
|
||||
certSecret:
|
||||
description: |-
|
||||
CertSecret is the name of the referenced Kubernetes Secret containing the client certificate.
|
||||
The client certificate is extracted from the keys `tls.crt` and `tls.key`.
|
||||
type: string
|
||||
insecureSkipVerify:
|
||||
description: InsecureSkipVerify defines whether the server
|
||||
certificates should be validated.
|
||||
type: boolean
|
||||
type: object
|
||||
writeTimeout:
|
||||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
description: |-
|
||||
WriteTimeout defines the timeout for socket write operations.
|
||||
Default value is 3 seconds.
|
||||
pattern: ^([0-9]+(ns|us|µs|ms|s|m|h)?)+$
|
||||
x-kubernetes-int-or-string: true
|
||||
type: object
|
||||
sourceCriterion:
|
||||
description: |-
|
||||
SourceCriterion defines what criterion is used to group requests as originating from a common source.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue