Add 'use regex' annotation to toggle nginx regex location modifier

This commit is contained in:
Zenara Daley 2018-10-01 13:54:11 -04:00
parent f56e839134
commit f29bdc3e8d
10 changed files with 325 additions and 39 deletions

View file

@ -451,9 +451,9 @@ http {
{{/* build the maps that will be use to validate the Whitelist */}}
{{ range $server := $servers }}
{{ $usesRewrite := atLeastOneNeedsRewrite $server.Locations }}
{{ $enforceRegex := enforceRegexModifier $server.Locations }}
{{ range $location := $server.Locations }}
{{ $path := buildLocation $location $usesRewrite }}
{{ $path := buildLocation $location $enforceRegex }}
{{ if isLocationAllowed $location }}
{{ if gt (len $location.Whitelist.CIDR) 0 }}
@ -885,9 +885,9 @@ stream {
{{ $server.ServerSnippet }}
{{ end }}
{{ $usesRewrite := atLeastOneNeedsRewrite $server.Locations }}
{{ $enforceRegex := enforceRegexModifier $server.Locations }}
{{ range $location := $server.Locations }}
{{ $path := buildLocation $location $usesRewrite }}
{{ $path := buildLocation $location $enforceRegex }}
{{ $proxySetHeader := proxySetHeader $location }}
{{ $authPath := buildAuthLocation $location }}
@ -1125,7 +1125,7 @@ stream {
{{ buildInfluxDB $location.InfluxDB }}
{{ if not (empty $location.Redirect.URL) }}
if ($uri ~* {{ $path }}) {
if ($uri ~* {{ stripLocationModifer $path }}) {
return {{ $location.Redirect.Code }} {{ $location.Redirect.URL }};
}
{{ end }}