我正在尝试将 local rate limit filter 添加到 front-proxy 示例。默认令牌桶按预期工作,但本地描述符的令牌桶没有。
这是我在 front-envoy.yaml 中的 route_config
更改:
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/service/2"
route:
cluster: service2
- match:
prefix: "/service/1"
route:
cluster: service1
rate_limits:
- actions:
# https://www.envoyproxy.io/docs/envoy/v1.18.2/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-ratelimit-action-requestheaders
- request_headers:
header_name: ":path"
descriptor_key: path
typed_per_filter_config:
envoy.filters.http.local_ratelimit:
"@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
stat_prefix: http_local_rate_limiter
# if there is no matching descriptor entries, the default token bucket is used
token_bucket:
max_tokens: 3
tokens_per_fill: 3
fill_interval: 60s
filter_enabled:
default_value:
numerator: 100
denominator: HUNDRED
filter_enforced:
default_value:
numerator: 100
denominator: HUNDRED
descriptors:
- entries:
- key: path
value: /service/1/foo/bar
token_bucket:
max_tokens: 1
tokens_per_fill: 1
fill_interval: 60s
我发送了 4 次 curl -v localhost:8080/service/1/foo/bar
并期望在第二个请求中得到 429 响应,以匹配本地描述符。
但我仅在第 4 次尝试时收到 429 响应:没有匹配的描述符条目,使用默认令牌桶。