Removing Server header from static content in IIS 7/8

后端 未结 5 1508
走了就别回头了
走了就别回头了 2021-02-01 15:53

As part of an effort to make our API and site more secure, I\'m removing headers that leak information about what the site is running.

Example before stripping headers:<

5条回答
  •  余生分开走
    2021-02-01 16:12

    Unfortunately managed code modules only work for code passing through the ASP.NET pipeline, whilst others have correctly suggested it is possible to force all requests through managed code, I personally feel this is less than desirable.

    In order to remove headers from all requests, including static content, which by default is served directly and not through managed code, it is possible to use a Native-Code module. Unfortunately Native-Code modules are a little more difficult to write as they use the win32 APIs rather than ASP.NET, however in my experience they are much more suitable to removing headers.

    The following link has binaries and source code for a Native-Code module that can be used to remove headers. It requires no extra configuration to remove the "Server" headers, but other headers to remove can be added in the IIS configuration.

    http://www.dionach.com/blog/easily-remove-unwanted-http-headers-in-iis-70-to-85

提交回复
热议问题