Add helper to verify if the configuration file changed
This commit is contained in:
parent
cad814cbb3
commit
5feb452ce4
8 changed files with 264 additions and 150 deletions
84
controllers/nginx-third-party/nginx.tmpl
vendored
84
controllers/nginx-third-party/nginx.tmpl
vendored
|
|
@ -1,9 +1,3 @@
|
|||
{{range $name, $upstream := .upstreams}}
|
||||
upstream {{$upstream.Name}} {
|
||||
{{range $server := $upstream.UpstreamServers}}
|
||||
server {{$server.Address}}:{{$server.Port}};{{end}}
|
||||
}{{end}}
|
||||
|
||||
{{ $cfg := .cfg }}{{ $sslCertificates := .sslCertificates }}{{ $defErrorSvc := .defErrorSvc }}{{ $defBackend := .defBackend }}
|
||||
daemon off;
|
||||
|
||||
|
|
@ -133,14 +127,13 @@ http {
|
|||
{{ end }}
|
||||
|
||||
{{ if $defErrorSvc }}
|
||||
# Custom error pages using
|
||||
# Custom error pages
|
||||
proxy_intercept_errors on;
|
||||
error_page 403 @custom_403;
|
||||
error_page 404 @custom_404;
|
||||
error_page 405 @custom_405;
|
||||
error_page 408 @custom_408;
|
||||
error_page 413 @custom_413;
|
||||
error_page 500 @custom_500;
|
||||
error_page 501 @custom_501;
|
||||
error_page 502 @custom_502;
|
||||
error_page 503 @custom_503;
|
||||
|
|
@ -179,12 +172,7 @@ http {
|
|||
#vhost_traffic_status_filter_by_host on;
|
||||
|
||||
location / {
|
||||
set $upstream_host '';
|
||||
set $upstream_port '';
|
||||
access_by_lua_block {
|
||||
require("ingress").content(ngx)
|
||||
}
|
||||
proxy_pass http://$upstream_host:$upstream_port$request_uri;
|
||||
return 200;
|
||||
}
|
||||
|
||||
{{ if $defErrorSvc }}{{ template "CUSTOM_ERRORS" (dict "cfg" $cfg "defErrorSvc" $defErrorSvc) }}{{ end }}
|
||||
|
|
@ -195,7 +183,6 @@ http {
|
|||
# TODO: support more than one certificate
|
||||
server {
|
||||
listen 443 ssl http2 default_server;
|
||||
|
||||
{{ range $sslCert := .sslCertificates }}{{ if $sslCert.Default }}
|
||||
# default certificate in case no match
|
||||
ssl_certificate "{{ $sslCert.Cert }}";
|
||||
|
|
@ -210,29 +197,38 @@ http {
|
|||
}
|
||||
{{ end }}
|
||||
|
||||
{{range $name, $upstream := .upstreams}}
|
||||
upstream {{$upstream.Name}} {
|
||||
least_conn;
|
||||
{{range $server := $upstream.Backends}}server {{$server.Address}}:{{$server.Port}};
|
||||
{{end}}
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{ range $server := .servers }}
|
||||
server {
|
||||
listen 80;
|
||||
{{ if $server.SSL }}
|
||||
listen 443 ssl http2;
|
||||
ssl_certificate {{ $server.SSLCertificate }};
|
||||
ssl_certificate_key {{ $server.SSLCertificateKey }};
|
||||
{{ end }}
|
||||
listen 80;
|
||||
{{ if $server.SSL }}listen 443 ssl http2;
|
||||
ssl_certificate {{ $server.SSLCertificate }};
|
||||
ssl_certificate_key {{ $server.SSLCertificateKey }};{{ end }}
|
||||
|
||||
server_name {{ $server.Name }};
|
||||
server_name {{ $server.Name }};
|
||||
{{ if $server.SSL }}
|
||||
if ($scheme = http) {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
{{ end }}
|
||||
{{ range $location := $server.Locations }}
|
||||
location {{ $location.Path }} {
|
||||
proxy_set_header Host $host;
|
||||
proxy_pass http://{{ $location.Upstream.Name }};
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ if $server.SSL }}
|
||||
if ($scheme = http) {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
{{ end }}
|
||||
{{ if $defErrorSvc }}{{ template "CUSTOM_ERRORS" (dict "cfg" $cfg "defErrorSvc" $defErrorSvc) }}{{ end }}
|
||||
|
||||
{{ range $location := $server.Locations }}
|
||||
location {{ $location.Path }} {
|
||||
proxy_set_header Host $host;
|
||||
proxy_pass http://{{ $location.Upstream.Name }};
|
||||
}{{ end }}
|
||||
}{{ end }}
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
# default server, including healthcheck
|
||||
server {
|
||||
|
|
@ -243,21 +239,7 @@ http {
|
|||
access_log off;
|
||||
return 200;
|
||||
}
|
||||
|
||||
# route to get the current Ingress configuration used in ingress.lua
|
||||
location /config {
|
||||
content_by_lua_block {
|
||||
require("ingress").config(ngx)
|
||||
}
|
||||
}
|
||||
|
||||
# route to post the list of Ingress rules to use.
|
||||
location /update-ingress {
|
||||
content_by_lua_block {
|
||||
require("ingress").update_ingress(ngx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
location /health-check {
|
||||
access_log off;
|
||||
proxy_pass http://127.0.0.1:10249/healthz;
|
||||
|
|
@ -320,12 +302,6 @@ stream {
|
|||
}
|
||||
}
|
||||
|
||||
location @custom_500 {
|
||||
content_by_lua_block {
|
||||
openURL(500, dev_error_url)
|
||||
}
|
||||
}
|
||||
|
||||
location @custom_501 {
|
||||
content_by_lua_block {
|
||||
openURL(501, dev_error_url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue