当前位置: 首页 > news >正文

nginx 隐藏版本号与WEB服务器信息(yum)

安全审计中有时会有

漏洞名称 HTTP服务器版本信息泄漏
漏洞描述 目标服务器返回的信息头中包含了Web Server的软件或者版本信息。

可以安装 nginx的headers-more-nginx-module模块修改或隐藏响应头信息

一、安装
1.下载 headers-more-nginx-module

下载地址
https://github.com/openresty/headers-more-nginx-module/tags
wget https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.37.tar.gz
2.解压

tar -zxvf v0.37.tar.gz
解压后会多出一个headers-more-nginx-module-0.37文件夹
3.查看当前系统nginx信息

// 查看当前nginx加载的模块,这里使用的是yum安装的
nginx -V 

接下来操作的是yum安装的,如何编译第三方模块
4.下载对应版本的nginx,这里的版本必须和之前yum安装的NGINX版本一致

# 下载
wget http://nginx.org/download/nginx-1.26.1.tar.gz 

# 解压
[root@localhost tools]# tar -zxvf nginx-1.26.1.tar.gz
5.编译

# 先备份
cp /usr/sbin/nginx /usr/sbin/nginx_old

yum install gcc pcre-devel zlib-devel make unzip openssl-devel -y

cd nginx-1.26.1

这里的编译模块是复制之前yum安装的编译模块,nginx -V

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/headers-more-nginx-module-0.37/

在末尾添加 --add-module=/headers-more-nginx-module-0.37
注意路径【/headers-more-nginx-module-0.37】要换成你自己的

configure完成后进行make(如原本无nginx,make后还需make install)

6.复制新的nginx到目录
cp objs/nginx  /usr/sbin/nginx
7.重启nginx生效

二、测试
修改nginx配置文件,增加代码块
 1、隐藏版本

加入参数:server_tokens off;

效果(版本已经看不到了):

2、隐藏Server
加入参数 : more_clear_headers 'Server';

效果(已经看不到server了


 3、伪装Server
 加入参数: more_set_headers 'Server: my-server';

效果(server已经变成我们自定义的

 


http://www.mrgr.cn/news/57802.html

相关文章:

  • 【数据结构】包装类简单认识泛型-Java
  • 蓝桥杯注意事项
  • Linux基础IO
  • 08_实现 reactive
  • 如何解决JMeter响应数据乱码?
  • 【数据结构与算法】链表(上)
  • 用户身份和访问管理是保障企业数字化转型的安全基石
  • 地平线港交所挂牌上市,开启智能驾驶新征程
  • EFCore pgsql Join 查询
  • 502 错误码通常出现在什么场景?
  • c语言指针详解2
  • Java开发者必备!0元学习Maven环境最新版超详细配置教程
  • 安全见闻(9)——开阔眼界,不做井底之蛙
  • 排序算法在最坏情况下的性能差异:深入分析
  • dcef文件下载--程序节排坑二
  • 【Java】SpringBoot实现MySQL数据库的增删查改
  • 【ROS2】在启动文件launch中,配置节点崩溃后自动重启
  • 编程中的注意事项
  • 打印一张A4纸多少钱?
  • 精品推荐 | StarPure石蜡包埋样本DNA提取试剂盒
  • Linux:sh脚本
  • 【读书笔记·VLSI电路设计方法解密】问题21:为什么降低芯片的功耗如此重要
  • vuetify页面布局
  • Spring事务详解——面试必看!
  • 常见的磁盘挂载方式
  • 软考中级网络工程师,快背,都是精华知识点!