Skip to content

Commit

Permalink
Improve consistency of templates (#434)
Browse files Browse the repository at this point in the history
* Improve consistency of nginx templates
* Improve consistency of ingress templates
* Remove logic from templates that are not needed
  • Loading branch information
Dean-Coakley authored Nov 9, 2018
1 parent e3f5224 commit 54e9b4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
12 changes: 6 additions & 6 deletions internal/nginx/templates/nginx-plus.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ upstream {{$upstream.Name}} {
{{end}}
{{if $.Keepalive}}keepalive {{$.Keepalive}};{{end}}
{{- if $upstream.UpstreamServers -}}
{{- if $upstream.Queue }}
{{- if $upstream.Queue}}
queue {{$upstream.Queue}} timeout={{$upstream.QueueTimeout}}s;
{{- end -}}
{{- end }}
{{- end}}
}
{{- end}}

Expand Down Expand Up @@ -70,7 +70,7 @@ server {
}
{{- end}}

{{ with $jwt := $server.JWTAuth }}
{{with $jwt := $server.JWTAuth}}
auth_jwt_key_file {{$jwt.Key}};
auth_jwt "{{.Realm}}"{{if $jwt.Token}} token={{$jwt.Token}}{{end}};

Expand All @@ -86,7 +86,7 @@ server {

{{- range $healthCheck := $server.HealthChecks}}
location @hc-{{$healthCheck.UpstreamName}} {
{{- range $name, $header := $healthCheck.Headers }}
{{- range $name, $header := $healthCheck.Headers}}
proxy_set_header {{$name}} "{{$header}}";
{{- end }}
proxy_connect_timeout {{$healthCheck.TimeoutSeconds}}s;
Expand All @@ -111,7 +111,7 @@ server {
# location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}}
{{end}}
{{if $location.GRPC}}
{{if not $server.GRPCOnly}}
{{if not $server.GRPCOnly}}
error_page 400 @grpcerror400;
error_page 401 @grpcerror401;
error_page 403 @grpcerror403;
Expand All @@ -132,7 +132,7 @@ server {
{{$value}}{{end}}
{{- end}}

{{ with $jwt := $location.JWTAuth }}
{{with $jwt := $location.JWTAuth}}
auth_jwt_key_file {{$jwt.Key}};
auth_jwt "{{.Realm}}"{{if $jwt.Token}} token={{$jwt.Token}}{{end}};
{{end}}
Expand Down
19 changes: 8 additions & 11 deletions internal/nginx/templates/nginx-plus.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ events {
worker_connections {{.WorkerConnections}};
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
Expand All @@ -38,7 +37,7 @@ http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
{{- end }}
{{- end}}
access_log /var/log/nginx/access.log main;

sendfile on;
Expand All @@ -61,7 +60,6 @@ http {
{{if .SSLPreferServerCiphers}}ssl_prefer_server_ciphers on;{{end}}
{{if .SSLDHParam}}ssl_dhparam {{.SSLDHParam}};{{end}}


server {
listen 80 default_server{{if .ProxyProtocol}} proxy_protocol{{end}};
listen 443 ssl default_server{{if .HTTP2}} http2{{end}}{{if .ProxyProtocol}} proxy_protocol{{end}};
Expand All @@ -85,7 +83,7 @@ http {
}
}

{{- if .NginxStatus }}
{{- if .NginxStatus}}
# NGINX Plus APIs
server {
listen {{.NginxStatusPort}};
Expand All @@ -96,15 +94,15 @@ http {

location = /dashboard.html {
}
{{ range $value := .NginxStatusAllowCIDRs }}{{ if ne $value "" }}
allow {{$value}};{{ end }}
{{end}}
{{range $value := .NginxStatusAllowCIDRs}}
allow {{$value}};{{end}}

deny all;
location /api {
api write=off;
}
}
{{- end }}
{{- end}}

# NGINX Plus API over unix socket
server {
Expand Down Expand Up @@ -135,11 +133,10 @@ stream {
log_format stream-main '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time';
{{- end }}
{{- end}}

access_log /var/log/nginx/stream-access.log stream-main;

{{range $value := .StreamSnippets}}
{{$value}}
{{end}}
{{$value}}{{end}}
}
17 changes: 7 additions & 10 deletions internal/nginx/templates/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ events {
worker_connections {{.WorkerConnections}};
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
Expand All @@ -37,7 +36,7 @@ http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
{{- end }}
{{- end}}
access_log /var/log/nginx/access.log main;

sendfile on;
Expand Down Expand Up @@ -82,19 +81,18 @@ http {
}
}

{{- if .NginxStatus }}
{{- if .NginxStatus}}
# stub_status
server {
listen {{.NginxStatusPort}};
{{ range $value := .NginxStatusAllowCIDRs }}{{ if ne $value "" }}
allow {{$value}};{{ end }}
{{end}}
{{range $value := .NginxStatusAllowCIDRs}}
allow {{$value}};{{end}}
deny all;
location /stub_status {
stub_status;
}
}
{{- end }}
{{- end}}

include /etc/nginx/config-version.conf;
include /etc/nginx/conf.d/*.conf;
Expand All @@ -107,11 +105,10 @@ stream {
log_format stream-main '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time';
{{- end }}
{{- end}}

access_log /var/log/nginx/stream-access.log stream-main;

{{range $value := .StreamSnippets}}
{{$value}}
{{end}}
{{$value}}{{end}}
}

0 comments on commit 54e9b4a

Please sign in to comment.