0

To customize the behavior of the Nginx Ingress controller when it returns a status code of 500, you will need to modify the Nginx configuration to capture the status code and customize the response.

Here is an example of how you might do this using a snippet in the nginx.ingress.kubernetes.io/server-snippet annotation of an Ingress resource:

> nginx.ingress.kubernetes.io/server-snippet: |   
> location
> @ingress_service_custom_error_500 {
>     internal;
>     if (return 500){
>       add_header Content-Type application/json always;
>       return 403 "{\"msg\":\"TOKEN IS WRONG\"}";
>     }
>     return 500;   }

How to do it correctly

0 Answers0