diff --git a/nginx.tmpl b/nginx.tmpl index c6d7d4f..612de0f 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -274,7 +274,10 @@ server { {{ range $container := $containers }} {{/* Determine whether this container has specified a virtual path, or default to the / pattern */}} {{ $location := coalesce $container.Env.VIRTUAL_PATH "/" }} - location {{ $location }} { + {{ $is_regexp := hasPrefix "^" $location }} + {{ $modifier := when $is_regexp "~" "" }} + + location {{ $modifier }} '{{ $location }}' { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }}; @@ -326,7 +329,10 @@ server { {{/* Determine whether this container has specified a virtual path, or default to the / pattern */}} {{ $location := coalesce $container.Env.VIRTUAL_PATH "/" }} - location {{ $location }} { + {{ $is_regexp := hasPrefix "^" $location }} + {{ $modifier := when $is_regexp "~" "" }} + + location {{ $modifier }} '{{ $location }}' { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $container.Name }};