apache调优技巧之一隐藏apahce版本信息
如果你的服务器版本信息是这样的,是很 危险的。# curl -I 192.168.1.38
HTTP/1.1 403 Forbidden
Date: Thu, 23 Mar 2017 08:46:31 GMT
Server: Apache/2.2.15 (CentOS)
Accept-Ranges: bytes
Content-Length: 5039
Connection: close
Content-Type: text/html; charset=UTF-8
要彻底将版本之类的信息进行改头换面,需要在编译之前修改源码包下include/ap_release.h文件
#pwd
/usr/local/src
# rm -rfhttpd-2.2.25
# tar zxf httpd-2.2.25.tar.gz
# cd httpd-2.2.25
# vim include/ap_release.h#修改源码中的版本信息为自己公司的相关信息,隐藏真实版本信息
改:
42 #define AP_SERVER_BASEVENDOR "Apache SoftwareFoundation"
43 #defineAP_SERVER_BASEPROJECT "Apache HTTP Server"
44 #defineAP_SERVER_BASEPRODUCT "Apache"
45
46 #defineAP_SERVER_MAJORVERSION_NUMBER 2
47 #defineAP_SERVER_MINORVERSION_NUMBER 2
48 #defineAP_SERVER_PATCHLEVEL_NUMBER 25
49 #defineAP_SERVER_DEVBUILD_BOOLEAN 0
为:
#define AP_SERVER_BASEVENDOR "xuegod"
#define AP_SERVER_BASEPROJECT "web server"
#define AP_SERVER_BASEPRODUCT "xuegod web server"
#define AP_SERVER_MAJORVERSION_NUMBER 8
#define AP_SERVER_MINORVERSION_NUMBER 1
#define AP_SERVER_PATCHLEVEL_NUMBER 2
#define AP_SERVER_DEVBUILD_BOOLEAN 3
注释:
#define AP_SERVER_BASEVENDOR "Apache SoftwareFoundation" #服务的供应商名称
#define AP_SERVER_BASEPROJECT "Apache HTTPServer"#服务的项目名称
#define AP_SERVER_BASEPRODUCT "Apache" #服务的产品名
#define AP_SERVER_MAJORVERSION_NUMBER 2#主要版本号
#define AP_SERVER_MINORVERSION_NUMBER 4#小版本号
#define AP_SERVER_PATCHLEVEL_NUMBER6#补丁级别
#define AP_SERVER_DEVBUILD_BOOLEAN0#
注:上述列出的行,大家可以修改成自己想要的,然后编译安装之后,再对httpd-default.conf文件进行修改,对方就彻底不知道你的版本号了。
源码编译安装apache
# pwd
/usr/local/src/httpd-2.2.25
# yum installopenssl*
# ./configure --prefix=/usr/local/apache2.2-xuegod --enable-so--enable-rewrite --enable-ssl--enable-deflate--enable-expires #检查安装环境并生成Makefile文件
配置参数用途:
--prefix=/usr/local/apache2.2 #指定安装路径
--enable-so# 支持动态加载模块
--enable-rewrite#支持网站地址重写
--enable-ssl# 支持ssl加密
--enable-deflate#支持页面传输前进行压缩
--enable-expires#支持设置网页缓存的时间
编译:
# make -j4#把源代码编译成可执行的二进制文件。
安装:
# make install
启动apache:
配置apache 可以开机启动并且可以使用service命令启动apache服务器
#cp /usr/local/apache2.2-xuegod/bin/apachectl /etc/init.d/apachectl-xuegod
测试:隐藏apache版本信息
# curl -I192.168.1.39
HTTP/1.1 200 OK
Date: Sat, 29 Aug 201509:43:44 GMT
Server: xuegod web server/8.1.2-dev (Unix) mod_ssl/8.1.2-devOpenSSL/1.0.0-fips
Last-Modified: Sat, 29 Aug2015 09:37:36 GMT
ETag:"6d086-3a-51e6ff35dba19"
Accept-Ranges: bytes
Content-Length: 58
Content-Type: text/html
已经看不到apache版本相关内容了
页:
[1]