我目前正在尝试配置Envoy路由以删除Envoy放置在那里的server
标头。
我已经尝试使用response_headers_to_remove
[1]字段。它适用于许多领域(x-content-type-options
,x-powered-by
等),但不适用于server
。
我使用的是Envoy Proxy 1.7.0.
[1] https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto config-route-v3-route
我发现这是可能的。
HTTPConnectionManager有一个名为ServerHeaderTransformation的设置:
OVERWRITE
(DEFAULT) Overwrite any Server header with the contents of server_name.
APPEND_IF_ABSENT
If no Server header is present, append Server server_name If a Server header is present, pass it through.
PASS_THROUGH
Pass through the value of the server header, and do not append a header if none is present.
通过将此更改为PASS_THROUGH
, Envoy将不会添加此标题。
要解决后端服务添加此报头的情况,请使用路由的response_headers_to_remove
字段。
Envoy将server
标头本身添加到响应中,因此response_headers_to_remove
似乎是不可能的。您也可以参考envoy/issues/14421,这是相同的问题,并提到了一个可能的解决方案。