From 6a2f8c7fcd5f024d0e77fc364857a1813eda26be Mon Sep 17 00:00:00 2001 From: Stefan Fussenegger Date: Thu, 30 Mar 2017 10:02:04 +0200 Subject: [PATCH] forward published port set by PORT_HTTP and PORT_HTTPS --- nginx.tmpl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nginx.tmpl b/nginx.tmpl index a5b1d32..8d0b199 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -24,11 +24,20 @@ map $http_x_forwarded_proto $proxy_x_forwarded_proto { '' $scheme; } +# Set $docker_port to published port using PORT_HTTP or PORT_HTTPS +{{ $httpPort := coalesce $.Env.PORT_HTTP "80" }} +{{ $httpsPort := coalesce $.Env.PORT_HTTPS "443" }} +map $scheme $docker_port { + default $server_port; + http {{ $httpPort }}; + https {{ $httpsPort }}; +} + # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the # server port the client connected to map $http_x_forwarded_port $proxy_x_forwarded_port { default $http_x_forwarded_port; - '' $server_port; + '' $docker_port; } # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any