From db2532fdcbf3328f0603ff90493680ef1678fbc8 Mon Sep 17 00:00:00 2001 From: James Ravn Date: Wed, 3 Aug 2022 12:23:09 +0100 Subject: [PATCH] fix(nginx.tmpl): port_in_redirect off For locations with a trailing prefix like `/foo/`, nginx will redirect any requests `/foo` to `/foo/`. By default, it redirects to the internal listen port which likely will not match the port the external client uses. Therefore, we should always preserve the external port the client uses to access ingress. --- nginx/nginx.tmpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nginx/nginx.tmpl b/nginx/nginx.tmpl index ba1a9cb..fb06c09 100644 --- a/nginx/nginx.tmpl +++ b/nginx/nginx.tmpl @@ -51,6 +51,9 @@ http { # Remove the Server header from the response which will have `nginx` more_clear_headers Server; + # When redirecting, such as /prefix -> /prefix/, don't use the internal listen port. Instead, preserve the client port. + port_in_redirect off; + {{ if .ClientHeaderBufferSize }} # Sets buffer size for reading client request header. client_header_buffer_size {{ .ClientHeaderBufferSize }}k;