Merge pull request #1074 from aledbf/rem-lua

Remove lua and use fastcgi to render errors
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-08-07 22:15:32 -04:00 committed by GitHub
commit cf732e846e
36 changed files with 259 additions and 4178 deletions

View file

@ -1,3 +1,4 @@
{{ $all := . }}
{{ $cfg := .Cfg }}
{{ $IsIPV6Enabled := .IsIPV6Enabled }}
{{ $healthzURI := .HealthzURI }}
@ -46,12 +47,6 @@ http {
vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;
{{ end }}
# lua section to return proper error codes when custom pages are used
lua_package_path '.?.lua;/etc/nginx/lua/?.lua;/etc/nginx/lua/vendor/lua-resty-http/lib/?.lua;';
init_by_lua_block {
require("error_page")
}
sendfile on;
aio threads;
tcp_nopush on;
@ -494,7 +489,7 @@ http {
}
{{ end }}
{{ template "CUSTOM_ERRORS" $cfg }}
{{ template "CUSTOM_ERRORS" $all }}
}
{{ end }}
@ -543,7 +538,7 @@ http {
set $proxy_upstream_name "upstream-default-backend";
proxy_pass http://upstream-default-backend;
}
{{ template "CUSTOM_ERRORS" $cfg }}
{{ template "CUSTOM_ERRORS" $all }}
}
# default server for services without endpoints
@ -553,9 +548,11 @@ http {
location / {
{{ if .CustomErrors }}
content_by_lua_block {
openURL(ngx.req.get_headers(0), 503)
}
include /etc/nginx/fastcgi_params;
fastcgi_param HTTP_X_Code 503;
fastcgi_param HTTP_X_Format $http_accept;
fastcgi_param HTTP_X_Endpoints {{ .DefaultBackendEndpoints }};
fastcgi_pass unix:/var/run/go-fastcgi.sock;
{{ else }}
return 503;
{{ end }}
@ -610,12 +607,15 @@ stream {
{{/* definition of templates to avoid repetitions */}}
{{ define "CUSTOM_ERRORS" }}
{{ range $errCode := .CustomHTTPErrors }}
{{ $defaultBackendEndpoints := .DefaultBackendEndpoints }}
{{ range $errCode := .Cfg.CustomHTTPErrors }}
location @custom_{{ $errCode }} {
internal;
content_by_lua_block {
openURL(ngx.req.get_headers(0), {{ $errCode }})
}
include /etc/nginx/fastcgi_params;
fastcgi_param HTTP_X_Code {{ $errCode }};
fastcgi_param HTTP_X_Format $http_accept;
fastcgi_param HTTP_X_Endpoints {{ $defaultBackendEndpoints }};
fastcgi_pass unix:/var/run/go-fastcgi.sock;
}
{{ end }}
{{ end }}