-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to remove HTTP response headers in the HTTP connection manager after HTTP filters have executed #37946
Comments
I sort of expected response_headers_to_remove to handle this, but I don't think it does (maybe it used to). cc @alyssawilk |
For a test: I added a network listener with 2 http filters: health-check filter in Because the http router filter is last, it also modifies response headers first so it's too late then. Another option might be adding a filter in front to remove the response headers but it would require extra care about filter ordering. My proposal is to add this ability to unconditionally remove response headers, even ones added by http filters running before the http router. |
@henrymwang You can have HeaderMutation as the first filter in the chain and specify any headers you'd like to remove from the outgoing response in response_mutations. On the response path, the filter chain is reversed and this filter would be invoked last. This way you won't be depending on the router filter to do the mutations for you as you have correctly identified that any other filters in the chain could mutate the response after the router filter have already executed. |
I've tried that as well without any luck - I believe that's because this extension only works on the HTTP connection manager's request path and it doesn't apply currently to response headers. Code snippets:
|
@henrymwang Could you link your Envoy config? |
Title: Add ability to remove HTTP response headers in the HTTP connection manager after HTTP filters have executed
Description:
The HTTP connection manager offers early header request mutations which run before HTTP filters:
envoy/api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto
Line 678 in 0038ebb
envoy/source/common/http/conn_manager_impl.cc
Line 1372 in 0038ebb
We have a similar need for stripping response headers after HTTP filters have executed. This would be useful in situations where HTTP filters might add response headers unintentionally that we'd like to ensure are never leaked.
This could be implemented by adding a new field to the HTTP connection manager config and updating
encodeHeaders
here,envoy/source/common/http/conn_manager_impl.cc
Line 1788 in 0038ebb
We can prepare a patch if this sounds reasonable.
[optional Relevant Links:]
The text was updated successfully, but these errors were encountered: