From 36868fb63ca9ec6e64c70c2bb385ed323e2956fa Mon Sep 17 00:00:00 2001 From: Mohammed Noureldin Date: Thu, 4 Jan 2018 20:18:00 +0100 Subject: [PATCH] Add port to to the header in Nginx config (#5101) * Add port to to the header in Nginx config Using `$host` only for the header in Nginx config causes that Kestrel knows only that its host name is *hostname.com* without any port. That will cause problems in redirecting (e.g. to login page). I added the `$server_port` as well. So the hostname will become *hostname.com:8080* for example. That solves any related redirecting problems. * Using $http_host in nginx config `$http_host` is more accurate that `$host` because if includes the port number. using `$host` will cause problems when running kestrel behind reverse proxy on ports other than the standard ports (80 and 443). --- aspnetcore/publishing/linuxproduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/publishing/linuxproduction.md b/aspnetcore/publishing/linuxproduction.md index 032116b8e9..6eec23ed55 100644 --- a/aspnetcore/publishing/linuxproduction.md +++ b/aspnetcore/publishing/linuxproduction.md @@ -116,7 +116,7 @@ server { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; - proxy_set_header Host $host; + proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; } }