Set proxy host header to the exact value of the request host header#827
Merged
Conversation
pleshakov
approved these changes
Jul 7, 2023
sjberman
approved these changes
Jul 7, 2023
kate-osborn
force-pushed
the
fix/use-http-host
branch
from
July 7, 2023 16:35
d321f99 to
8da6a9c
Compare
kate-osborn
force-pushed
the
fix/use-http-host
branch
from
July 7, 2023 18:03
8da6a9c to
c2a97fd
Compare
miledxz
added a commit
to miledxz/nginx-gateway-fabric
that referenced
this pull request
Jan 14, 2025
…ginx#827) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
$hostnginx 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_hostnginx 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_hostcan 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
Closes #797
Checklist
Before creating a PR, run through this checklist and mark each as complete.