<p>Is there any way to remove a header going upstream after the external authentication with the envoy proxy? We planned to migrate to envoy proxy for our internal API gateway, but this is a blocker now.</p>

<p>For example: the external authentication service gets the request and processes the authentication header, in case the validation fails, it throws the 401. But if it succeeds, I want to prevent the auth headers from going upstream. </p>

<p>As per the documentation <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/api-v2/config/filter/http/ext_authz/v2alpha/ext_authz.proto#envoy-api-msg-config-filter-http-ext-authz-v2alpha-httpservice" rel="noreferrer">Ext Auth</a>:</p>

<blockquote>
  <p>A successful check allows the authorization service adding or overriding headers from the original request before dispatching it to the upstream. This is done by configuring which headers in the authorization response should be sent to the upstream. See allowed_authorization_headers below.</p>
</blockquote>

<p>There is no mention whether I can completely remove the header going upstream. </p>

<p>I have the option to override the headers, but that is causing header conflict at the upstream servers. So it is not a possible solution.</p>

<p>How can I achieve this?</p>

Ysak
<p>Note that I am not an expert in envoy proxy, but from what I was able to find you can actually write a Lua script that would be able to remove the headers. In the documentation you can find an example of such script, and with a little bit of tinkering you should be able to customize it if needed:</p>

<pre class="lang-lua prettyprint-override"><code>-- Remove a response header named 'foo'
response_handle:headers():remove("foo")
</code></pre>

<p>You can find more information in the official documentation. Here for <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/api-v2/config/filter/http/lua/v2/lua.proto#config-filter-http-lua-v2-lua" rel="nofollow noreferrer">config.filter.http.lua.v2.Lua</a> and here are the <a href="https://www.envoyproxy.io/docs/envoy/v1.9.0/configuration/http_filters/lua_filter#script-examples" rel="nofollow noreferrer">script examples</a>. </p>
