gpt4 book ai didi

azure - Service Fabric - 删除 ReverseProxy 服务器 header 'Microsoft-HTTPAPI/2.0'

转载 作者:行者123 更新时间:2023-12-03 05:47:17 24 4
gpt4 key购买 nike

我有一个在 asp.net core 2.1/kestrel 上运行的无状态服务。该服务受到保护,并通过 LB 和 SF 反向代理从外部访问。 Service Fabric 版本为 6.3.187.9494。

我需要从响应中完全删除服务器 header ,并且通过操作 KestrelServerOptions.AddServerHeader 在服务本身中执行此操作没有问题,但似乎 ReverseProxy 添加了自己的服务 header ,即 Microsoft -HTTPAPI/2.0

以下是我的检查方法 - 我从运行服务的节点向服务端点发出请求,但没有得到服务器 header 。然后我通过反向代理执行相同的操作,然后返回 - 服务器:Microsoft-HTTPAPI/2.0。

通读ApplicationGateway/Http设置中,我找到了名为 RemoveServiceResponseHeaders 的属性 -

Semi colon/ comma-separated list of response headers that will be removed from the service response; before forwarding it to the client. If this is set to empty string; pass all the headers returned by the service as-is. i.e do not overwrite the Date and Server

我已将其设置为“日期;服务器”并更新了集群,但运气不佳,因为我仍然收到该服务器 header 。

有什么建议吗?

最佳答案

恐怕您无法使用 ServiceFabric 中的传统“RemoveServiceResponseHeaders”配置来完成此操作。它只会删除从您的服务响应中收到的读者。

在 Windows 上,Service Fabric HttpGateway 运行在 HTTP.sys 内核模块之上,该模块负责此 header ,SF 对此没有发言权。

Before I go further,

if you are removing this for security reasons, you should rethink about using the built in ApplicationGateway provided by SF, it will expose all you services and currently there is no control on which service are exposed through it, I think the risk is higher than just removing the server header, as it does not expose the real server name.

更进一步,

要解决您的问题,您有两种选择:

  1. 您可以使用HTTP.sys注册表settings将其从机器上删除。

您需要在注册表项 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters 中添加 DisableServerHeader DWORD 值,并将其值设置为 2 .

enter image description here

This key controls how http.sys behaves with regards to appending thehttp response header "Server" for responses that it sends to clients.A value of 0, which is the default value, will use the header valuethe application provides to http.sys, or will append the default valueof ‘Microsoft-HTTPAPI/2.0’ to the response header. A value of 1 willnot append the "Server" header for responses generated by http.sys(responses ending in 400, 503, and other status codes). A value of 2will prevent http.sys from appending a ‘Server’ header to theresponse. If a 'Server' header is present on the response, it will notbe removed, if one is not present, it will not be added.

请查看此答案,其中包含有关如何操作的详细信息:GET request to IIS returns Microsoft-HttpApi/2.0

.

  • 根据上面的描述,响应 header 包含“Microsoft-HTTPAPI/2.0”,因为默认值为 0,并且原始响应不包含服务器 header ,如果您提供任何值,系统将使用该值。另外,将 SF 配置为不从响应中删除服务器 header ,将RemoveServiceResponseHeaders 配置设置为仅“日期”之类的内容,因为默认值为“日期;服务器”
  • 关于azure - Service Fabric - 删除 ReverseProxy 服务器 header 'Microsoft-HTTPAPI/2.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52722055/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com