Change Error Handling on 503 and 404

Hi,

I am looking for a way to change kongs behavior in error cases. Especially 503 if no backend is found and 404 if no ingress matches.
I do NOT want to handle http errors coming from the pods/upstream.

In my first try I added the following lines to the nginx-kong.conf in /usr/local/kong (using the docker proxy 2.2)

“add_header Lukas SERVER;”
after
“server_name kong;” (at the beginning of the server block) and

“add_header Lukas HANDLER;”
after
“/kong_error_handler {” (at the beginning of the kong_error_handler location block)

The result is:

  • Positive responses have the Lukas:Server Header (EXPRECTED)
  • Negative 404 responses on a non-existing subdomain/ingress have no Lukas Header (NOT EXPECTED)
  • Negative 503 responses on non-existing backend pods have no Lukas Header (NOT EXPECTED)

Can somebody tell me why this is? Are these errors not routed via the kong_error_handler location block? Or does Kong remove my added header in “Kong.handle_error()”?

Please help me. I would like to change the behavior of kong on kong (non-upstream) errors…

Thankx a lot
Lukas