Allow forwarding headers from auth_request
without flattening
#12880
Labels
kind/feature
Categorizes issue or PR as related to a new feature.
needs-priority
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
Currently, ingress-nginx flattens multiple occurrences of the same header returned by
auth_request
into a single header with comma-separated values. This behavior prevents proper forwarding of multiple headers with the same name, which is required for certain use cases such as Kubernetes impersonation headers.For example, when the
auth_request
response includes:ingress-nginx transforms this into:
This is problematic because upstream applications expecting separate headers receive a single combined header instead.
Proposal:
Introduce a mechanism in Ingress NGINX that allows forwarding multiple headers as separate entries instead of flattening them.
Suggested Implementation
The following Lua script demonstrates how to properly forward multiple headers from
auth_request
usingngx_req.add_header
, which ensures that repeated headers are preserved:Usage
This Lua script can be integrated into an Ingress NGINX configuration like this:
Expected Behavior
With this change, multiple headers of the same name are forwarded separately to the upstream application instead of being merged into a single comma-separated value.
Current implementation
The current implementation responsible for handling headers in
auth_request
is located in:/~https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/controller/template/template.go#L578-L611 and /~https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/template/nginx.tmpl#L1182-L1209.
Note that it already uses lua to evaluate these headers most of the time.
A modification to this logic should allow preserving multiple headers instead of flattening them.
Benefits
auth_request
headers.Would the Ingress NGINX maintainers be open to reviewing a PR for this feature?
The text was updated successfully, but these errors were encountered: