<p>I have a working installation of Kong on a Kubernetes cluster, using kubernetes-ingress-controller functionality (<a href="https://github.com/Kong/kubernetes-ingress-controller" rel="nofollow noreferrer">https://github.com/Kong/kubernetes-ingress-controller</a>).</p>

<p>I would like to remove the following Kong's related headers:</p>

<ul>
<li>"X-Kong-Upstream-Latency"</li>
<li>"X-Kong-Proxy-Latency"</li>
<li>"Via"</li>
<li>"Server"</li>
</ul>

<p>I tried by using the response-transformer plugin by applying the following KongPlugin resource:</p>

<pre><code>apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: kong-response-transformer
config:
  remove:
    headers:
    - "X-Kong-Upstream-Latency"
    - "X-Kong-Proxy-Latency"
    - "Via"
    - "Server"
plugin: response-transformer
</code></pre>

<p>But only the "Server" header is removed from responses. Is there a way to remove such headers from response in a "kubernetes-ingress-controller" way by using some custom resources?</p>

<p>I found several GitHub issues related to this problem (<a href="https://github.com/Kong/kong/issues/1009" rel="nofollow noreferrer">1</a>, <a href="https://github.com/Kong/kong/issues/1315" rel="nofollow noreferrer">2</a>) but all of them refers to the possibility to update the Kong configuration file (/etc/kong/kong.yml) and I honestly don't know how to apply such changes in my Kubernetes environment. Passing the following lines into a ConfigMap does not fix the problem:</p>

<pre><code># Add additional response headers
header_filter_by_lua_block {
    kong.header_filter()
    ngx.header["Server"] = nil
    ngx.header["Via"] = nil
    ngx.header["X-Kong-Proxy-Latency"] = nil
    ngx.header["X-Kong-Upstream-Latency"] = nil
}
</code></pre>

<p>Any help on this?
Thank you...</p>

<p>Edit: Kong version is 2.0.3, kong-ingress-controller version is 0.8.1.</p>

Marco
<p>You can disable these headers via the <a href="https://docs.konghq.com/2.0.x/configuration/#headers" rel="noreferrer"><code>headers</code></a> configuration property. Also noted on the same page is the fact that configuration properties can also be specified as <a href="https://docs.konghq.com/2.0.x/configuration/#environment-variables" rel="noreferrer">environment variables</a>.</p>

<p>You can thus update your Deployment to specify the <code>headers = off</code> property as an environment variable. Something similar to:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingress-kong
  namespace: kong
spec:
  template:
    spec:
      containers:
        name: proxy
        image: kong:2.0.3
        env:
        - name: KONG_HEADERS
          value: off
</code></pre>
