From e43bac1521084762788de3c72d908cd55a34cf56 Mon Sep 17 00:00:00 2001 From: martianrock Date: Wed, 30 Aug 2017 01:11:25 -0400 Subject: [PATCH 1/2] Update nginx.tmpl Add support for trailing slash in location subdir via NGINX_PROXY_SUBDIRECTORY_TRAILING_SLASH variable --- nginx.tmpl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nginx.tmpl b/nginx.tmpl index 4199bde..e932f98 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -28,7 +28,13 @@ upstream {{ $subdir }} { {{ define "locations" }} {{ range $subdir, $containers := groupByMulti $ "Env.NGINX_PROXY_SUBDIRECTORY" "," }} - location /{{ $subdir }} { + {{ $trailing_slash := or (first (groupByKeys $containers "Env.NGINX_PROXY_SUBDIRECTORY_TRAILING_SLASH")) "1" }} + {{ if eq $trailing_slash "1" }} + location /{{ $subdir }}/ { + {{ else }} + location /{{ $subdir }} { + {{ end }} + {{ $proto := or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http" }} {{ $map_to_root := or (first (groupByKeys $containers "Env.NGINX_PROXY_SUBDIRECTORY_MAP_TO_ROOT")) "1" }} {{ if eq $map_to_root "1" }} From e3379db008840244af644152a7eb6326db9a832b Mon Sep 17 00:00:00 2001 From: martianrock Date: Wed, 30 Aug 2017 01:29:50 -0400 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9a0e07a..f5bf7d4 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,5 @@ A docker image based on jwilder/nginx-proxy which modifies the template to have * NGINX_PROXY_SUBDIRECTORY [REQUIRED]: Specifies the subdirectory to use for this container. If multiple containers have the same subdirectory, nginx will load balance those requests. * NGINX_PROXY_SUBDIRECTORY_MAP_TO_ROOT: If 0, maps /$subdir to /$subdir. If 1, maps /$subdir to /. Defaults to 1. +* NGINX_PROXY_SUBDIRECTORY_TRAILING_SLASH: If 0, location is /$subdir. If 1, location is /$subdir/. Defaults to 1. * VIRTUAL_PROTO: Protocol to use for connection to backend container. Defaults to http.