Merge pull request #2486 from flant/vars
Extend kubernetes interrelation variables in nginx.tmpl
This commit is contained in:
commit
fc96d5cd54
1 changed files with 10 additions and 6 deletions
|
@ -182,6 +182,7 @@ http {
|
||||||
# $namespace
|
# $namespace
|
||||||
# $ingress_name
|
# $ingress_name
|
||||||
# $service_name
|
# $service_name
|
||||||
|
# $service_port
|
||||||
log_format upstreaminfo {{ if $cfg.LogFormatEscapeJSON }}escape=json {{ end }}'{{ buildLogFormatUpstream $cfg }}';
|
log_format upstreaminfo {{ if $cfg.LogFormatEscapeJSON }}escape=json {{ end }}'{{ buildLogFormatUpstream $cfg }}';
|
||||||
|
|
||||||
{{/* map urls that should not appear in access.log */}}
|
{{/* map urls that should not appear in access.log */}}
|
||||||
|
@ -663,6 +664,7 @@ stream {
|
||||||
proxy_set_header X-Namespace $namespace;
|
proxy_set_header X-Namespace $namespace;
|
||||||
proxy_set_header X-Ingress-Name $ingress_name;
|
proxy_set_header X-Ingress-Name $ingress_name;
|
||||||
proxy_set_header X-Service-Name $service_name;
|
proxy_set_header X-Service-Name $service_name;
|
||||||
|
proxy_set_header X-Service-Port $service_port;
|
||||||
|
|
||||||
rewrite (.*) / break;
|
rewrite (.*) / break;
|
||||||
|
|
||||||
|
@ -833,6 +835,13 @@ stream {
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
location {{ $path }} {
|
location {{ $path }} {
|
||||||
|
{{ $ing := (getIngressInformation $location.Ingress $location.Path) }}
|
||||||
|
set $namespace "{{ $ing.Namespace }}";
|
||||||
|
set $ingress_name "{{ $ing.Rule }}";
|
||||||
|
set $service_name "{{ $ing.Service }}";
|
||||||
|
set $service_port "{{ $location.Port }}";
|
||||||
|
set $location_path "{{ $location.Path }}";
|
||||||
|
|
||||||
{{ if not $all.DisableLua }}
|
{{ if not $all.DisableLua }}
|
||||||
rewrite_by_lua_block {
|
rewrite_by_lua_block {
|
||||||
{{ if $all.DynamicConfigurationEnabled}}
|
{{ if $all.DynamicConfigurationEnabled}}
|
||||||
|
@ -912,12 +921,6 @@ stream {
|
||||||
|
|
||||||
set $proxy_upstream_name "{{ buildUpstreamName $server.Hostname $all.Backends $location $all.DynamicConfigurationEnabled }}";
|
set $proxy_upstream_name "{{ buildUpstreamName $server.Hostname $all.Backends $location $all.DynamicConfigurationEnabled }}";
|
||||||
|
|
||||||
{{ $ing := (getIngressInformation $location.Ingress $location.Path) }}
|
|
||||||
{{/* $ing.Metadata contains the Ingress metadata */}}
|
|
||||||
set $namespace "{{ $ing.Namespace }}";
|
|
||||||
set $ingress_name "{{ $ing.Rule }}";
|
|
||||||
set $service_name "{{ $ing.Service }}";
|
|
||||||
|
|
||||||
{{/* redirect to HTTPS can be achieved forcing the redirect or having a SSL Certificate configured for the server */}}
|
{{/* redirect to HTTPS can be achieved forcing the redirect or having a SSL Certificate configured for the server */}}
|
||||||
{{ if (or $location.Rewrite.ForceSSLRedirect (and (not (empty $server.SSLCertificate)) $location.Rewrite.SSLRedirect)) }}
|
{{ if (or $location.Rewrite.ForceSSLRedirect (and (not (empty $server.SSLCertificate)) $location.Rewrite.SSLRedirect)) }}
|
||||||
{{ if not (isLocationInLocationList $location $all.Cfg.NoTLSRedirectLocations) }}
|
{{ if not (isLocationInLocationList $location $all.Cfg.NoTLSRedirectLocations) }}
|
||||||
|
@ -1091,6 +1094,7 @@ stream {
|
||||||
proxy_set_header X-Namespace $namespace;
|
proxy_set_header X-Namespace $namespace;
|
||||||
proxy_set_header X-Ingress-Name $ingress_name;
|
proxy_set_header X-Ingress-Name $ingress_name;
|
||||||
proxy_set_header X-Service-Name $service_name;
|
proxy_set_header X-Service-Name $service_name;
|
||||||
|
proxy_set_header X-Service-Port $service_port;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if not (empty $location.Backend) }}
|
{{ if not (empty $location.Backend) }}
|
||||||
|
|
Loading…
Reference in a new issue