在 Apache2 中删除 http 标头 [英] Removing http headers in Apache2

查看:19
本文介绍了在 Apache2 中删除 http 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Apache2.2.9 托管站点上,我想删除下面的标题.

On an Apache2.2.9 hosted site, I would like to remove the headers below.

2010 年 12 月 16 日星期四 17:49:45 GMT服务器阿帕奇保活超时=15,最大值=92连接保持活动

Date Thu, 16 Dec 2010 17:49:45 GMT Server Apache Keep-Alive timeout=15, max=92 Connection Keep-Alive

让我先讨论一下删除服务器和日期是否正确/合法/好:我已经阅读了标准,但我仍然想这样做.节省的字节数很大(平均响应大小约为 200B).

Let me preempt the discussion on whether or not it it right/legal/nice to remvoe Server and Date: I have read the standard and I still want to do it. The bytes saved are significant (average response size is ~200B).

在我的 site.conf 中(最后从 apache2.conf 加载)我试过这个没有成功:

In my site.conf (last load from apache2.conf) I have tried this with no success:

    Header unset Date
    Header unset Server
    Header unset Connection 
    Header unset Keep-Alive

其他未设置的 Header 指令确实有效(因此加载了 mod_headers).

Other Header unset directives do work (so mod_headers is loaded).

推荐答案

你有没有注意到这个错误报告?无法取消设置某些标头是 Apache 中的一个设计问题.附加的补丁包含一种删除服务器标头的方法.简单地看一下,似乎可以在 modules/http/http_filters.c 的第 1000 行附近完成其余不需要的默认包含的标头...

Have you noticed this bug report? The inability to unset certain headers is a design issue in Apache. The patch attached contains a way to remove the Server header. Looking at it briefly it seems that lobotomizing the rest of the unwanted default included headers can be done at modules/http/http_filters.c, around line 1000...

这篇关于在 Apache2 中删除 http 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆