Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the use of relative redirects #12161

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

chriss-de
Copy link
Contributor

@chriss-de chriss-de commented Oct 11, 2024

With this PR it is possible to use relative redirects as described in RFC7231 (section 7.1.2).
Nginx has a config flag absolute_redirect that is on by default and cannot be changed via annotation or configmap.
This PR allows the user to switch absolute_redirect off.
This annotation/configmap setting is named relative-redirect and inverses the logic to not conflict with the default settings.

What this PR does / why we need it:

This change let you use relative redirects instead of the absolute redirects nginx uses in default.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • CVE Report (Scanner found CVE and adding report)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

#12162

How Has This Been Tested?

This PR includes e2e tests

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added unit and/or e2e tests to cover my changes.
  • All new and existing tests passed.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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 added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 11, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority labels Oct 11, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @chriss-de. Thanks for your PR.

I'm waiting for a kubernetes 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.

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/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 11, 2024
Copy link

netlify bot commented Oct 11, 2024

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
🔨 Latest commit 7bd28bb
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/67331c58b7589d0008526297

fixed typo in e2e fct call
@longwuyuan
Copy link
Contributor

@chriss-de thanks for your contribution

Could you consider creating an issue first for this. It would help so much if a layman needed complete descriptive and accurate explaining of what the problem is why it is important for the project to change its code, is available as issue description (along with the answers to questions asked in the template of a new bug report). Additionally it will help to know how many users benefit from the proposed changes.

Many things happened and so some decisions were made. We focus now on security & Gateway-API . We also deprecated multiple features that are potentially popular but don't help in maintaining & supporting a secure & stable controller. Hence absolute critical definitive data is needed during triaging, as the resources are really strained so not possible for developers to triage and clone and test etc etc etc.

thanks

@@ -125,6 +125,11 @@ type Backend struct {
// Default: false
UsePortInRedirects bool `json:"use-port-in-redirects"`

// Enables or disables relative redirects. By default nginx uses absolute redirects.
// http://nginx.org/en/docs/http/ngx_http_core_module.html#absolute_redirect
// Default: false
Copy link
Member

Choose a reason for hiding this comment

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

If the default current is true, we should keep it that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well yes. Thats why the config value relative-redirects is default false - so the nginx config flag absolute_redirect can be true (as it is in default).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could make it all (configmap & annotation) with the name absolute-redirect
But then you would have to add an annotation (or configmap) where you set the value explicitly to false to get the behavior. Works both for me.
First thought was to inverse the logic of absolute_redirect to relative-redirects so you have to say yes to get the new behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so?! leave at it is? resolved?

@chriss-de
Copy link
Contributor Author

golangci-lint gets OOM killed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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.

4 participants