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

Set proxy host header to the exact value of the request host header #827

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

kate-osborn
Copy link
Contributor

Proposed changes

Problem: The Gateway API expects the response host header to match the exact value of the request host header. We set the proxy host header to the $host nginx variable, which does not include any characters after :. This causes a conformance test to fail where the host header contains a port.

Solution: Set the proxy host header to $http_host nginx variable when it is non-empty. This variable contains the unmodified host header of the request. However, in an HTTP/1.0 request, it's possible that $http_host can be empty. In this case, we will use the value of $host. See http://nginx.org/en/docs/http/ngx_http_core_module.html#var_host.

Testing: Ran impacted conformance test

--- PASS: TestConformance (22.30s)
    --- PASS: TestConformance/HTTPRouteHostnameIntersection (9.04s)

Closes #797

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

@kate-osborn kate-osborn requested a review from a team as a code owner July 7, 2023 16:02
@github-actions github-actions bot added the bug Something isn't working label Jul 7, 2023
@kate-osborn kate-osborn merged commit 36d5df4 into nginxinc:main Jul 7, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Incorrect host returned for request with port
3 participants