Skip to content

Ingress NGINX - Support Redirect#299

Merged
k8s-ci-robot merged 30 commits intokubernetes-sigs:mainfrom
jgreeer:ingress-nginx/support-redirect
Feb 27, 2026
Merged

Ingress NGINX - Support Redirect#299
k8s-ci-robot merged 30 commits intokubernetes-sigs:mainfrom
jgreeer:ingress-nginx/support-redirect

Conversation

@jgreeer
Copy link
Copy Markdown
Contributor

@jgreeer jgreeer commented Jan 9, 2026

What type of PR is this?

Fixes #268

Does this PR introduce a user-facing change?:

Add support for `nginx.ingress.kubernetes.io/permanent-redirect` and `nginx.ingress.kubernetes.io/temporal-redirect` + warnings for `nginx.ingress.kubernetes.io/proxy-redirect-from` and `nginx.ingress.kubernetes.io/proxy-redirect-to`

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 9, 2026
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 9, 2026
@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 9, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @jgreeer. 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 the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 9, 2026
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2026
@jgreeer
Copy link
Copy Markdown
Contributor Author

jgreeer commented Jan 15, 2026

nginx.ingress.kubernetes.io/from-to-www-redirect, nginx.ingress.kubernetes.io/permanent-redirect-code, and nginx.ingress.kubernetes.io/temporal-redirect-code require 307/308 status code support, so they cannot be implemented until v1.5 release.

@jgreeer jgreeer marked this pull request as ready for review January 16, 2026 18:16
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 16, 2026
@k8s-ci-robot k8s-ci-robot requested a review from rikatz January 16, 2026 18:16
@Stevenjin8
Copy link
Copy Markdown
Contributor

tbh gwapi 1.5 is just around the corner. I think we can merge this as is. WDYT @mikemorris

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 23, 2026
@jgreeer
Copy link
Copy Markdown
Contributor Author

jgreeer commented Jan 23, 2026

tbh gwapi 1.5 is just around the corner. I think we can merge this as is. WDYT @mikemorris

this doesn't have the 307/308 status codes, it emits warnings for them. so we can merge now and then make another PR later for the status code annotations.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 23, 2026
@Stevenjin8
Copy link
Copy Markdown
Contributor

/ok-to-test

@jgreeer
Copy link
Copy Markdown
Contributor Author

jgreeer commented Feb 13, 2026

Changed approach to the following:

  • Iterate through all rules in the IR
  • Find a rule that has a source ingress with a redirect annotation
  • Add the redirect filter to that rule using values from URL.parse()
  • Remove backendRef from that rule (yaml isn't accepted if we don't do this)
  • Keep existing backendSource since it still contributed that rule

Also, always override the path with "/" if no path is provided in the redirect annotation. Gateway api will keep the path from the match in the redirect, ingress-nginx does not.

continue
}

// Get ingress from the first backend source (all backends in a rule should come from the same ingress)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don thtink this is true. What about canary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, but when you combine canary and redirect the redirect takes priority and no canary happens. Are there other situations where we might need to check other backend sources?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgreeer can you fix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought you were agreeing. So fix to account for when canary is enabled? What would that look like?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I was thinking of using'getNonCanaryIngress'

}

// Warn about unsupported custom status code annotation
if ingress.Annotations[TemporalRedirectCodeAnnotation] != "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its the TemporalRedirectCodeAnnotation is 301, its ok though. Also isn't the default 308 anyways? so we need to make a warning anyways.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*what if the TemporalRedirectCodeAnnotation is already 301

Copy link
Copy Markdown
Contributor Author

@jgreeer jgreeer Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default codes are 301/302. I will add a check for if the redirect code annotation is already a default though

Copy link
Copy Markdown
Contributor

@Stevenjin8 Stevenjin8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgreeer could you add an integration test now that we have them

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 18, 2026
chakravardhan added a commit to chakravardhan/ingress2gateway that referenced this pull request Feb 19, 2026
@Stevenjin8
Copy link
Copy Markdown
Contributor

/approve

@Stevenjin8
Copy link
Copy Markdown
Contributor

@kkk777-7 @spencerhance @bexxmodd could one of you take a look or lgtm this.

// Check custom status code annotation
if codeStr := ingress.Annotations[TemporalRedirectCodeAnnotation]; codeStr != "" {
code, err := strconv.Atoi(codeStr)
if err != nil || code != 302 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't HTTPRequestedRedirectFilter supports 303, 307, and 308 now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's about to release with v1.5, i'll go ahead and add it to this PR now

Comment thread pkg/i2gw/providers/ingressnginx/redirect.go
@bexxmodd
Copy link
Copy Markdown

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bexxmodd, jgreeer, Stevenjin8

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot merged commit 5b1691d into kubernetes-sigs:main Feb 27, 2026
5 checks passed
chakravardhan added a commit to chakravardhan/ingress2gateway that referenced this pull request Mar 31, 2026
k8s-ci-robot pushed a commit that referenced this pull request Apr 1, 2026
* feat(ingressnginx): add support for force-ssl-redirect and from-to-www-redirect annotations

* fix(ingressnginx): remove force-ssl-redirect support and document compatibility with #299

* fix(ingressnginx): correct from-to-www-redirect hostnames and gateway generation

* test(e2e): add e2e integration test for from-to-www-redirect and conform to GatewayAPI 301 validation

* style: fix gofmt error in e2e verifiers

* fix(ingressnginx): Fix from-to-www-redirect sectionName API validation and Lexicographic precedence

* Fix syntax and redeclaration errors in merge resolution

* rebased
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ingress NGINX] Support Redirect

5 participants