How to remove the server name from the error page returned by nginx ingress controller?

12/18/2019

I want to remove the server name from the error pages returned by the Kubernetes Nginx ingress controller. I added the server tokens to be false which takes care of the headers but when I curl or open the ingress in the browser I still get the server name.

server-tokens : "False"

enter image description here

I want to get rid of the server name while returning a 404 or any other error for that matter. What is the easiest way to achieve this? I don't have a default backend. Is there any way I can edit the ingress for this backend and add a custom HTML page directly without having to deploy default backends or inject the page using the nginx-configmap?

-- Anshul Tripathi
kubernetes
kubernetes-ingress
nginx
nginx-config
nginx-ingress

1 Answer

12/18/2019

server-tokens only removes info from the HTTP response header. You'll need to define custom error pages similar to

server {
  ...

  error_page 500 502 503 504 /custom_50x.html;
}

http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page

-- AnthumChris
Source: StackOverflow