Skip to content

Commit

Permalink
Set grpc :authority header from request header (kubernetes#8912)
Browse files Browse the repository at this point in the history
This is to fix that the `:authority` header is  set to `upstream_balancer`
  • Loading branch information
lapwingcloud authored Jun 27, 2023
1 parent 643c475 commit a21b521
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1388,13 +1388,11 @@ stream {
{{ end }}

{{/* By default use vhost as Host to upstream, but allow overrides */}}
{{ if not (eq $proxySetHeader "grpc_set_header") }}
{{ if not (empty $location.UpstreamVhost) }}
{{ $proxySetHeader }} Host {{ $location.UpstreamVhost | quote }};
{{ else }}
{{ $proxySetHeader }} Host $best_http_host;
{{ end }}
{{ end }}

# Pass the extracted client certificate to the backend
{{ if not (empty $server.CertificateAuth.CAFileName) }}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/annotations/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var _ = framework.DescribeAnnotation("backend-protocol - GRPC", func() {

metadata := res.GetMetadata()
assert.Equal(ginkgo.GinkgoT(), metadata["content-type"].Values[0], "application/grpc")
assert.Equal(ginkgo.GinkgoT(), metadata[":authority"].Values[0], host)
})

ginkgo.It("authorization metadata should be overwritten by external auth response headers", func() {
Expand Down

0 comments on commit a21b521

Please sign in to comment.