I need to apply a rate limit policy on Nginx Kubernetes Ingress Controller by decoded value from JWT token.
So I'd use as key
of rateLimit
field of Policy
a JWT field.
I'm using Kubernetes 1.25 and NGINX 3.0.2
Can you help me?
apiVersion: k8s.nginx.org/v1
kind: Policy
metadata:
name: rate-limit-policy
spec:
rateLimit:
rate: 10r/s
key: <JTW FIELD>
zoneSize: 10M
---
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: api-vs
spec:
ingressClassName: nginx-api
host: api.example.com
policies:
- name: rate-limit-policy
upstreams:
- name: api
service: api
port: 80
routes:
- path: /
action:
pass: api