From 6625f394ce6b6af5ec08fe322124a0c017ce16a5 Mon Sep 17 00:00:00 2001 From: Or Koren Date: Mon, 31 Jul 2023 11:40:40 +0300 Subject: [PATCH] interceptor: don't override Host header Signed-off-by: Or Koren --- CHANGELOG.md | 1 + interceptor/handler/upstream.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6ff3ec4..d9971111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This changelog keeps track of work items that have been completed and are ready - **Operator**: Remove ScaledObject `name` & `app` custom labels ([#717](https://github.com/kedacore/http-add-on/issues/717)) - **Interceptor**: fatal error: concurrent map iteration and map write ([#726](https://github.com/kedacore/http-add-on/issues/726)) - **Interceptor**: Provide graceful shutdown for http servers on SIGINT and SIGTERM ([#731](https://github.com/kedacore/http-add-on/issues/731)) +- **Interceptor**: Keep original Host in the Host header ([#731](https://github.com/kedacore/http-add-on/issues/331)) - **Scaler**: Provide graceful shutdown for grpc server on SIGINT and SIGTERM ([#731](https://github.com/kedacore/http-add-on/issues/731)) ### Deprecations diff --git a/interceptor/handler/upstream.go b/interceptor/handler/upstream.go index c3658c6e..b1260523 100644 --- a/interceptor/handler/upstream.go +++ b/interceptor/handler/upstream.go @@ -37,10 +37,11 @@ func (uh *Upstream) ServeHTTP(w http.ResponseWriter, r *http.Request) { } proxy := httputil.NewSingleHostReverseProxy(stream) + superDirector := proxy.Director proxy.Transport = uh.roundTripper proxy.Director = func(req *http.Request) { + superDirector(req) req.URL = stream - req.Host = stream.Host req.URL.Path = r.URL.Path req.URL.RawQuery = r.URL.RawQuery // delete the incoming X-Forwarded-For header so the proxy