Remove lua and use fastcgi to render errors
This commit is contained in:
parent
7b38e5a36e
commit
a091d3ede7
35 changed files with 251 additions and 4160 deletions
|
|
@ -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 }}
|
||||
|
|
@ -608,12 +605,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 }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue