Custom errors should be optional
This commit is contained in:
parent
e93d8d8152
commit
5faa855e66
2 changed files with 51 additions and 24 deletions
|
@ -123,18 +123,23 @@ http {
|
||||||
ssl_dhparam {{ .sslDHParam }};
|
ssl_dhparam {{ .sslDHParam }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $interceptHttpErrors := $cfg.interceptHttp403 || $cfg.interceptHttp404 || $cfg.interceptHttp405 ||
|
||||||
|
$cfg.interceptHttp408 || $cfg.interceptHttp413 || $cfg.interceptHttp501 ||
|
||||||
|
$cfg.interceptHttp502 || $cfg.interceptHttp503 || $cfg.interceptHttp504 }}
|
||||||
|
{{ if $interceptHttpErrors }}
|
||||||
# Custom error pages
|
# Custom error pages
|
||||||
proxy_intercept_errors on;
|
proxy_intercept_errors on;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
error_page 403 = @custom_403;
|
{{ if $cfg.interceptHttp403 }}error_page 403 = @custom_403;{{ end }}
|
||||||
error_page 404 = @custom_404;
|
{{ if $cfg.interceptHttp404 }}error_page 404 = @custom_404;{{ end }}
|
||||||
error_page 405 = @custom_405;
|
{{ if $cfg.interceptHttp405 }}error_page 405 = @custom_405;{{ end }}
|
||||||
error_page 408 = @custom_408;
|
{{ if $cfg.interceptHttp408 }}error_page 408 = @custom_408;{{ end }}
|
||||||
error_page 413 = @custom_413;
|
{{ if $cfg.interceptHttp413 }}error_page 413 = @custom_413;{{ end }}
|
||||||
error_page 501 = @custom_501;
|
{{ if $cfg.interceptHttp501 }}error_page 501 = @custom_501;{{ end }}
|
||||||
error_page 502 = @custom_502;
|
{{ if $cfg.interceptHttp502 }}error_page 502 = @custom_502;{{ end }}
|
||||||
error_page 503 = @custom_503;
|
{{ if $cfg.interceptHttp503 }}error_page 503 = @custom_503;{{ end }}
|
||||||
error_page 504 = @custom_504;
|
{{ if $cfg.interceptHttp504 }}error_page 504 = @custom_504;{{ end }}
|
||||||
|
|
||||||
# In case of errors try the next upstream server before returning an error
|
# In case of errors try the next upstream server before returning an error
|
||||||
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504 {{ if $cfg.retryNonIdempotent }}non_idempotent{{ end }};
|
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504 {{ if $cfg.retryNonIdempotent }}non_idempotent{{ end }};
|
||||||
|
@ -285,59 +290,67 @@ stream {
|
||||||
|
|
||||||
{{/* definition of templates to avoid repetitions */}}
|
{{/* definition of templates to avoid repetitions */}}
|
||||||
{{ define "CUSTOM_ERRORS" }}
|
{{ define "CUSTOM_ERRORS" }}
|
||||||
|
{{ if $cfg.interceptHttp403 }}
|
||||||
location @custom_403 {
|
location @custom_403 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(403)
|
openURL(403)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp404 }}
|
||||||
location @custom_404 {
|
location @custom_404 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(404)
|
openURL(404)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp405 }}
|
||||||
location @custom_405 {
|
location @custom_405 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(405)
|
openURL(405)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp408 }}
|
||||||
location @custom_408 {
|
location @custom_408 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(408)
|
openURL(408)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp413 }}
|
||||||
location @custom_413 {
|
location @custom_413 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(413)
|
openURL(413)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp501 }}
|
||||||
|
location @custom_501 {
|
||||||
|
internal;
|
||||||
|
content_by_lua_block {
|
||||||
|
openURL(501)
|
||||||
|
}
|
||||||
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp502 }}
|
||||||
location @custom_502 {
|
location @custom_502 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(502)
|
openURL(502)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp503 }}
|
||||||
location @custom_503 {
|
location @custom_503 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(503)
|
openURL(503)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
|
{{ if $cfg.interceptHttp504 }}
|
||||||
location @custom_504 {
|
location @custom_504 {
|
||||||
internal;
|
internal;
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
openURL(504)
|
openURL(504)
|
||||||
}
|
}
|
||||||
}
|
}{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -124,6 +124,20 @@ type nginxConfiguration struct {
|
||||||
// accessed using HTTPS.
|
// accessed using HTTPS.
|
||||||
HSTSMaxAge string `structs:"hsts-max-age,omitempty"`
|
HSTSMaxAge string `structs:"hsts-max-age,omitempty"`
|
||||||
|
|
||||||
|
// enables or disable if HTTP codes should be passed to a client or be redirected to nginx for
|
||||||
|
// processing with the error_page directive
|
||||||
|
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
|
||||||
|
// By default this is disabled
|
||||||
|
InterceptHTTP403 bool `structs:"intercept-error-403,omitempty"`
|
||||||
|
InterceptHTTP404 bool `structs:"intercept-error-404,omitempty"`
|
||||||
|
InterceptHTTP405 bool `structs:"intercept-error-405,omitempty"`
|
||||||
|
InterceptHTTP408 bool `structs:"intercept-error-408,omitempty"`
|
||||||
|
InterceptHTTP413 bool `structs:"intercept-error-413,omitempty"`
|
||||||
|
InterceptHTTP501 bool `structs:"intercept-error-502,omitempty"`
|
||||||
|
InterceptHTTP502 bool `structs:"intercept-error-502,omitempty"`
|
||||||
|
InterceptHTTP503 bool `structs:"intercept-error-503,omitempty"`
|
||||||
|
InterceptHTTP504 bool `structs:"intercept-error-504,omitempty"`
|
||||||
|
|
||||||
// Time during which a keep-alive client connection will stay open on the server side.
|
// Time during which a keep-alive client connection will stay open on the server side.
|
||||||
// The zero value disables keep-alive client connections
|
// The zero value disables keep-alive client connections
|
||||||
// http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
|
||||||
|
|
Loading…
Reference in a new issue