Skip to content

feat(ingressnginx): implement x-forwarded-prefix annotation support#319

Closed
asklokesh wants to merge 1 commit intokubernetes-sigs:mainfrom
asklokesh:fix/header-manipulation-271
Closed

feat(ingressnginx): implement x-forwarded-prefix annotation support#319
asklokesh wants to merge 1 commit intokubernetes-sigs:mainfrom
asklokesh:fix/header-manipulation-271

Conversation

@asklokesh
Copy link
Copy Markdown

Summary

Implements support for header manipulation annotations as requested in #271.

Annotations addressed:

  • nginx.ingress.kubernetes.io/x-forwarded-prefix - Implemented: Sets X-Forwarded-Prefix request header
  • nginx.ingress.kubernetes.io/custom-headers - Improved warning: Explains that ConfigMap reading is not supported during migration
  • nginx.ingress.kubernetes.io/connection-proxy-header - Already implemented (sets Connection header)
  • nginx.ingress.kubernetes.io/upstream-vhost - Already implemented (sets Host header)

Implementation details:

  • x-forwarded-prefix is skipped in headers.go when rewrite-target is also present (rewrite.go handles it in that case to avoid duplicate processing)
  • Improved custom-headers warning message to guide users on manual migration
  • Fixed typo in annotations.go comment

Changes:

  • annotations.go: Fixed "R2gex" -> "Regex" typo
  • headers.go: Added x-forwarded-prefix support with rewrite-target coordination, improved custom-headers warning
  • headers_test.go: Added test cases for x-forwarded-prefix, skip-when-rewrite-present, and no-annotations edge cases

Fixes #271

Test plan

  • Unit tests added and passing
  • Verified x-forwarded-prefix header is set correctly
  • Verified x-forwarded-prefix is not duplicated when rewrite-target is present
  • All existing tests pass

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jan 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: asklokesh
Once this PR has been reviewed and has the lgtm label, please assign stevenjin8 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Jan 24, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: asklokesh / name: Lokesh Mure (21dd3f1)

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @asklokesh. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 24, 2026
Adds support for the nginx.ingress.kubernetes.io/x-forwarded-prefix
annotation by setting the X-Forwarded-Prefix request header.

Changes:
- Added x-forwarded-prefix handling in headers.go with logic to skip
  processing when rewrite-target is present (handled by rewrite.go)
- Improved custom-headers warning message to explain ConfigMap limitation
- Fixed typo in annotations.go comment (R2gex -> Regex)
- Added comprehensive test cases including edge cases

Related to kubernetes-sigs#271
@asklokesh asklokesh force-pushed the fix/header-manipulation-271 branch from 34f1bc0 to 21dd3f1 Compare January 24, 2026 21:23
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 24, 2026
@asklokesh
Copy link
Copy Markdown
Author

/easycla

@asklokesh
Copy link
Copy Markdown
Author

asklokesh commented Jan 27, 2026

Closing this PR as header manipulation was already implemented and merged in PR #283 by @eladmotola, and additional header work is being done in PR #291 by @Stevenjin8. checklist item added to have checked for existing PRs before starting.

@asklokesh asklokesh closed this Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ingress NGINX] Implement Header Maniputation

2 participants