Skip to content

Unable to get X-RateLimit-* or retryafter response headers from NGINX Ingress Controller #13809

@Asha680

Description

@Asha680

We are leveraging rate limiting at the NGINX Ingress Controller level for our Kubernetes setup. Our goal is to include the following response headers so that clients can implement retry mechanisms based on rate limit values:
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset (if configured)
What we tried:
Added the above headers using configuration-snippet in the ingress annotation.
Applied the rate-limiting annotations (nginx.ingress.kubernetes.io/limit-req-*).
Hit the rate limit intentionally to verify headers.
Issue:
When the rate limit is exceeded, the response only includes default headers such as HTTP status code and Server and it do not show any custom headers. We expected these to reflect current limit, remaining requests, and reset time.
Questions:
Are there any official annotations or configuration options in Ingress-NGINX that support sending these X-RateLimit-* or retryafter headers automatically?
If not, is there a recommended way to dynamically populate these headers based on $limit_req variables?
Details
Ingress-NGINX version: v 4.12.2 [Helm chart]
Kubernetes version: v1.30.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions