diff --git a/kong/core/error_handlers.lua b/kong/core/error_handlers.lua index 642ebead6b6b..751ee683b169 100644 --- a/kong/core/error_handlers.lua +++ b/kong/core/error_handlers.lua @@ -12,6 +12,13 @@ local xml_template = '\n%s local html_template = 'Kong Error

Kong Error

%s.

' local BODIES = { + s404 = "Not found", + s408 = "Request timeout", + s411 = "Length required", + s412 = "Precondition failed", + s413 = "Payload too large", + s414 = "URI too long", + s417 = "Expectation failed", s500 = "An unexpected error occurred", s502 = "An invalid response was received from the upstream server", s503 = "The upstream server is currently unavailable", @@ -48,4 +55,4 @@ return function(ngx) ngx.header["Server"] = SERVER_HEADER ngx.header["Content-Type"] = content_type ngx.say(format(template, message)) -end +end \ No newline at end of file diff --git a/kong/templates/nginx_kong.lua b/kong/templates/nginx_kong.lua index 3624d97d7dc8..cea3da821613 100644 --- a/kong/templates/nginx_kong.lua +++ b/kong/templates/nginx_kong.lua @@ -60,7 +60,8 @@ init_worker_by_lua_block { server { server_name kong; listen ${{PROXY_LISTEN}}; - error_page 500 502 503 504 /50x; + error_page 404 408 411 412 413 414 417 /kong_error_handler; + error_page 500 502 503 504 /kong_error_handler; > if ssl then listen ${{PROXY_LISTEN_SSL}} ssl; @@ -100,7 +101,7 @@ server { } } - location = /50x { + location = /kong_error_handler { internal; content_by_lua_block { require('kong.core.error_handlers')(ngx) @@ -140,4 +141,4 @@ server { return 200 'User-agent: *\nDisallow: /'; } } -]] +]] \ No newline at end of file diff --git a/spec/02-integration/05-proxy/01-resolver_spec.lua b/spec/02-integration/05-proxy/01-resolver_spec.lua index 42f750e1090e..05d4c4db3f7d 100644 --- a/spec/02-integration/05-proxy/01-resolver_spec.lua +++ b/spec/02-integration/05-proxy/01-resolver_spec.lua @@ -358,5 +358,6 @@ describe("Resolver", function() } }) assert.res_status(414, res) + assert.match(meta._NAME.."/"..meta._VERSION, res.headers["server"]) end) -end) +end) \ No newline at end of file