diff --git a/nginx.tmpl b/nginx.tmpl index 59bd62a..31b204a 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -297,17 +297,35 @@ server { {{ $is_regexp := hasPrefix "^" $location }} {{ $modifier := when $is_regexp "~" "" }} + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} location {{ $modifier }} '{{ $location }}' { + return 302 '{{ $location }}/'; + } + {{ end }} + + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + location {{ $modifier }} '{{ $location }}/' { + {{ else }} + location {{ $modifier }} '{{ $location }}' { + {{ end }} {{ if eq $proto "uwsgi" }} include uwsgi_params; + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}/; + {{ else }} uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}; + {{ end }} {{ else if eq $proto "fastcgi" }} root {{ trim $vhost_root }}; include fastcgi_params; fastcgi_pass {{ trim $container.Name }}; {{ else }} + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + proxy_pass {{ trim $proto }}://{{ trim $container.Name }}/; + {{ else }} proxy_pass {{ trim $proto }}://{{ trim $container.Name }}; {{ end }} + {{ end }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; @@ -352,17 +370,35 @@ server { {{ $is_regexp := hasPrefix "^" $location }} {{ $modifier := when $is_regexp "~" "" }} + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} location {{ $modifier }} '{{ $location }}' { + return 302 '{{ $location }}/'; + } + {{ end }} + + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + location {{ $modifier }} '{{ $location }}/' { + {{ else }} + location {{ $modifier }} '{{ $location }}' { + {{ end }} {{ if eq $proto "uwsgi" }} include uwsgi_params; + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}/; + {{ else }} uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}; + {{ end }} {{ else if eq $proto "fastcgi" }} root {{ trim $vhost_root }}; include fastcgi_params; fastcgi_pass {{ trim $container.Name }}; {{ else }} + {{ if (eq $container.Env.VIRTUAL_PATH_STRIP "TRUE") }} + proxy_pass {{ trim $proto }}://{{ trim $container.Name }}/; + {{ else }} proxy_pass {{ trim $proto }}://{{ trim $container.Name }}; {{ end }} + {{ end }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};