一、环境的搭建
实验环境:
操作系统:Centos 7.4
[root[email protected] ~]# ls apr-1.6.3.tar.gz apr-util-1.6.1.tar.bz2 httpd-2.4.33.tar.gz pcre-8.41.tar.gz #主要的按照包,下面是具体的安装操作 [[email protected] ~]# yum install -y bzip2 [[email protected] ~]# tar xf apr-1.6.3.tar.gz [[email protected] ~]# ls apr-1.6.3 apr-1.6.3.tar.gz apr-util-1.6.1.tar.bz2 httpd-2.4.33.tar.gz pcre-8.41.tar.gz [[email protected] ~]# cd apr-1.6.3 [[email protected] apr-1.6.3]# yum install -y gcc gcc-c++ #安装依赖包 [[email protected] apr-1.6.3]# ./configure --prefix=/usr/local/apr [[email protected] apr-1.6.3]# make && make install [[email protected] ~]# tar xf apr-util-1.6.1.tar.bz2 [[email protected] ~]# cd apr-util-1.6.1 [[email protected] apr-util-1.6.1]# ./configure [[email protected] apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config [[email protected] apr-util-1.6.1]# yum install expat-devel -y #安装依赖包 [[email protected] apr-util-1.6.1]# make && make install [[email protected] ~]# tar xf pcre-8.41.tar.gz [[email protected] ~]# cd pcre-8.41 [[email protected] pcre-8.41]# ./configure --prefix=/usr/local/pcre [[email protected] pcre-8.41]# make && make install
二、隐藏Apache版本信息
1. 屏蔽apache版本等敏感信息
#查看apache版本信息: [[email protected] ~]# curl -I 192.168.1.63 HTTP/1.1 200 OK Date: Sun, 15 Nov 2015 12:40:59 GMT Server: Apache/2.4.33 (Unix) mod_ssl/2.4.33 OpenSSL/1.0.0-fips PHP/5.4.14 X-Powered-By: PHP/5.4.14 Content-Type: text/html [[email protected] ~]# curl -I www.baidu.com HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform Connection: Keep-Alive Content-Length: 277 Content-Type: text/html Date: Mon, 16 Jul 2018 08:32:29 GMT Etag: "575e1f71-115" Last-Modified: Mon, 13 Jun 2016 02:50:25 GMT Pragma: no-cache Server: bfe/1.0.8.18 [[email protected] ~]# curl -I www.tencent.com HTTP/1.1 200 OK Server: NWS_UGC_HY Connection: keep-alive Date: Mon, 16 Jul 2018 08:32:58 GMT Cache-Control: max-age=600 Expires: Mon, 16 Jul 2018 08:42:58 GMT Last-Modified: Fri, 17 Feb 2017 02:11:37 GMT Content-Type: text/html Content-Length: 189 X-NWS-LOG-UUID: 0f1c8273-b0fa-4d9c-87ae-f6d9c5c8ca99 989f50f8bc1bbda11f966c017556085f X-Cache-Lookup: Hit From Disktank [[email protected] ~]# curl -I www.taobao.com HTTP/1.1 302 Found Server: Tengine Date: Mon, 16 Jul 2018 08:33:17 GMT Content-Type: text/html Content-Length: 258 Connection: keep-alive Location: https://www.taobao.com/ Set-Cookie: thw=cn; Path=/; Domain=.taobao.com; Expires=Tue, 16-Jul-19 08:33:17 GMT; Strict-Transport-Security: max-age=31536000 1、我们在apache主配置文件httpd.conf中,找到包含httpd-default.conf的行,并解开注释 [[email protected] ~]# vim /usr/local/httpd/conf/httpd.conf 486 #Include conf/extra/httpd-default.conf 为: 486 Include conf/extra/httpd-default.conf 注意:编译安装的情况下,只有此行解开注释了,后面的修改才能生效。 2)打开httpd-default.conf文件,修改如下两个地方 [[email protected] ~]# vim /usr/local/httpd/conf/extra/httpd-default.conf #修改如下行 改: 55 ServerTokens Full 65 ServerSignature On 为: ServerTokens Prod ServerSignature Off 注: 服务器标记产品 服务器签名 重启服务: [[email protected] ~]# /etc/init.d/apachectl restart 测试: [[email protected] ~]# curl -I 192.168.1.63 HTTP/1.1 200 OK Date: Sat, 29 Aug 2015 09:07:00 GMT Server: Apache X-Powered-By: PHP/5.4.14 Content-Type: text/html 注:还是会出现信息:Server: Apache
原文地址:https://www.cnblogs.com/happy1983/p/9318479.html
时间: 2024-10-13 16:25:22