解决appscan扫描“下在应用程序中发现不必要的 Http 响应头”问题
问题原因:配置服务器以除去向所有外发请求发送的缺省“Server”头。也就是说我们送的请求头出现了 server:nginx 1.1.1这些信息。
说明:要想整个隐藏掉server整个信息,网上搜到的资料windows系统是无法实现。所以我这里也是用centos弄得。
解决方法:
注:centos系统安装好的基础上操作
一.nginx的安装
1.下载 nginx
$ cd /home # 进入指定目录,目录请自行选择
$ wget https://nginx.org/download/nginx-1.21.2.tar.gz # 下载安装包,版本请自行选择
2.cd 至 nginx 安装包所在目录,进行解压;
$ cd /home # 进入安装包所在目录
$ tar -zxvf nginx-1.21.2.tar.gz # 解压
3.cd 至解压后的目录,运行./configure 进行初始化配置; 注:如果初始化配置有问题的话,需要安装依赖包,没有的跳过一下安装内容
$ cd ./nginx-1.21.2 # 进入解压目录
$ ./configure # 运行./configure
安装内容
# 提示 error: the HTTP rewrite module requires the PCRE library.
$ yum install -y pcre pcre-devel
# 提示 error: Invalid C++ compiler or C++ compiler flags.
$ yum install -y gcc gcc-c++
# 提示 error: the HTTP gzip module requires the zlib library.
$ yum install -y zlib-devel
4.依赖包安装完后,返回 nginx 解压目录,再次运行 ./configure 进行初始化即可
$ cd /home/nginx-1.21.2 # 返回 nginx 解压目录
$ ./configure # 再次运行./configure
5在这一步需要下载这个headers-more-nginx-module插件用来去除server信息。下载地址:https://github.com/openresty/headers-more-nginx-module
注:这里可以使用git下载,如果centos系统中没有git的得先安装一个git,(自行搜索一下),不用git安装,也可以使用命令下载,以下,代码没有使用git安装。
我们nginx-1.21.2在下新建个tools文件下,把headers-more-nginx-module放入
$ cd /home/nginx-1.21.2
$ mkdir tools
$ cd tools #放到这里
$ wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
#解压
$ tar -zxvf v0.33.tar.gz
6.追加./configure --prefix=/root/home/nginx-1.21.2 (这里是nginx解压的路径) \ --add-module=/root/home/nginx-1.21.2/tools/headers-more-nginx-module(这里是下载插件的路径路径,选择自己的路径就行)
然后make,切记没有make install
$ cd /nginx-1.21.2
$ ./configure --prefix=/root/home/nginx-1.21.2 --add-module=/root/home/nginx- 1.21.2/tools/headers-more-nginx-module-0.33
$ make
7.然后在nginx.conf中添加
server:{
more_clear_headers 'Server';
more_clear_headers 'server';
}
8.重启一下nginx
$ cd /root/home/nginx-1.21.2/sbin
$ ./nginx -s stop #停止
$ ./nginx #启动
$ ps -ef | grep nginx #查看nginx状态,出现如下图内容说明启动成功
9完成
参考:
https://blog.csdn.net/Cs_Mervyn/article/details/120075477
https://blog.csdn.net/zzhongcy/article/details/115538272