-2

I have an application on a Kubernetes cluster that is deployed through Helm. The ingress controller is installed by the command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/baremetal/deploy.yaml

How to hide the nginx version from header responce?

At this moment I have next ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/server-tokens: "off"

So maybe i need change to traefik.ingress.kubernetes.io/response-headers: and some rules...

I'm checking response with curl -IL mysite.com In response i got next: Server: nginx/1.21.3

Give me and advice please)

i'm added nginx.ingress.kubernetes.io/server-tokens: "off" but it not help me. Expect to hide nginx version with helm update or kubectl install new ingress yaml

1 Answers1

0

In the official documentation for the nginx controller, it says:

https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/

Annotation onfigMap Key Description Description Default
nginx.org/server-tokens server-tokens Enables or disables the server_tokens directive. Additionally, with the NGINX Plus, you can specify a custom string value, including the empty string value, which disables the emission of the “Server” field. Default

I suspect the following annotation should work:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.org/server-tokens: false

Note you could also customise it with a ConfigMap according to the docs.

And related to your comment on:

traefik.ingress.kubernetes.io/response-headers

Traefik is another ingress controller different from the nginx one, the configuration won't be the same.

François
  • 1,793
  • 14
  • 19