From a21b5218a53476015c996e2588ac5837b20d37b0 Mon Sep 17 00:00:00 2001 From: Junrui Chen Date: Tue, 27 Jun 2023 16:30:30 +1000 Subject: [PATCH] Set grpc :authority header from request header (#8912) This is to fix that the `:authority` header is set to `upstream_balancer` --- rootfs/etc/nginx/template/nginx.tmpl | 2 -- test/e2e/annotations/grpc.go | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/rootfs/etc/nginx/template/nginx.tmpl b/rootfs/etc/nginx/template/nginx.tmpl index a1e02aae3..ccc86702d 100644 --- a/rootfs/etc/nginx/template/nginx.tmpl +++ b/rootfs/etc/nginx/template/nginx.tmpl @@ -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) }} diff --git a/test/e2e/annotations/grpc.go b/test/e2e/annotations/grpc.go index c8e530ead..243307df4 100644 --- a/test/e2e/annotations/grpc.go +++ b/test/e2e/annotations/grpc.go @@ -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() {