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

Updating from/to www redirect to use X-Forwarded-Proto #7623

Conversation

aloisbarreras
Copy link
Contributor

What this PR does / why we need it:

When running nginx ingress behind a load balancer (AWS ALB) that terminates SSL and using the following annotations:

    nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"

the ingress controller will incorrectly redirect the request from HTTPS -> HTTP for the from/to www redirect.

For example, a request to https://mysite.com will respond with a 308 to http://www.mysite.com.

I believe this is because the code uses ngx.var.scheme in the redirect_to value. Because the ingress controller is behind an external load balancer, the scheme is always HTTP. I am updating the logic to use the X-Forwarded-Proto value if the configmap option use-forwarded-headers is set to true.

Types of changes

  • [X ] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I have tested this in AWS with the above mentioned set up and can confirm that my changes will redirect to the appropriate scheme.

Checklist:

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

When running make test there is one test that fails to pass for me, but it doesn't seem to have anything to do with my changes. The test fails even when running on main so it's probably something to do with my environment set up. Let me know if I need to add/change any tests.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 10, 2021
@k8s-ci-robot
Copy link
Contributor

@aloisbarreras: 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Sep 10, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @aloisbarreras!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @aloisbarreras. 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 10, 2021
@aloisbarreras
Copy link
Contributor Author

Just signed the CLA

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 10, 2021
@aloisbarreras
Copy link
Contributor Author

@cmluciano @ElvinEfendi any feedback on this?

@aloisbarreras
Copy link
Contributor Author

@cmluciano @ElvinEfendi bumping this

@aloisbarreras
Copy link
Contributor Author

@cmluciano @ElvinEfendi bump

@aloisbarreras
Copy link
Contributor Author

@cmluciano @ElvinEfendi hello

@rikatz
Copy link
Contributor

rikatz commented Oct 24, 2021

/assign
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 24, 2021
@strongjz
Copy link
Member

I ran this PR locally and the failing test I saw was

goroutine 1 [running]:^M
sigs.k8s.io/controller-runtime/pkg/internal/testing/addr.init.0()^M
        /go/src/k8s.io/ingress-nginx/.modcache/sigs.k8s.io/controller-runtime@v0.9.5/pkg/internal/testing/addr/manager.go:51 +0xda^M
FAIL    k8s.io/ingress-nginx/internal/ingress/controller/store  0.025s^M

@strongjz
Copy link
Member

e2e test suite passed for me and all the k8s test passes in ci.

@strongjz
Copy link
Member

e2e passes locally for me as well

Ginkgo ran 1 suite in 4m29.580419544s
Test Suite Passed

@aloisbarreras
Copy link
Contributor Author

aloisbarreras commented Oct 27, 2021

awesome thank you for taking the time to review this. Is there anything else you need from me to get this merged? @strongjz

@aloisbarreras
Copy link
Contributor Author

Hey @strongjz is there anything you need here?

@aloisbarreras
Copy link
Contributor Author

how's it going @strongjz

@aloisbarreras
Copy link
Contributor Author

🎵 🎵 All I want for christmas is you 🎵 🎵 to merge this PR

@aloisbarreras
Copy link
Contributor Author

how's it going @rikatz

@aloisbarreras
Copy link
Contributor Author

yo yo @rikatz how's it going

@rikatz
Copy link
Contributor

rikatz commented Jan 12, 2022

hey @aloisbarreras sorry. I'm on a real rush this week. Wont make any promise but will try to prioritize this one ok?

Thanks!

@rikatz
Copy link
Contributor

rikatz commented Jan 12, 2022

Also I'm aware this PR took too long already and we should do something fast to review and get it merged, it's just about a lack of time here :/

@aloisbarreras
Copy link
Contributor Author

awesome thank you! :)

@rikatz
Copy link
Contributor

rikatz commented Jan 16, 2022

sorry for the delay, seems solid! thanks

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 16, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aloisbarreras, rikatz

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 16, 2022
@k8s-ci-robot k8s-ci-robot merged commit 0bc01f7 into kubernetes:main Jan 16, 2022
@tao12345666333 tao12345666333 mentioned this pull request Feb 27, 2022
rchshld pushed a commit to joomcode/ingress-nginx that referenced this pull request May 19, 2023
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. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants