0

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 

Michel Foucault
  • 1,724
  • 3
  • 25
  • 48
  • 1
    You might find this [thread](https://stackoverflow.com/questions/64263895/nginx-rate-limitting-by-decoded-values-from-jwt-token) useful – James S Apr 03 '23 at 11:11
  • Thanks, it's interesting, but I'm searching an example for nginx ingress controller for K8s. – Michel Foucault Apr 04 '23 at 15:46

0 Answers0