锋盈数科-知识库 Logo
首页
软件开发
计算机基础
Hello Halo
新手必读
关于本知识库
登录 →
锋盈数科-知识库 Logo
首页 软件开发 计算机基础 Hello Halo 新手必读 关于本知识库
登录
  1. 首页
  2. 专题栏目
  3. Nginx专题
  4. 隐藏nginx响应头中的server信息(HTTP服务器版本信息泄漏)

隐藏nginx响应头中的server信息(HTTP服务器版本信息泄漏)

0
  • Nginx专题
  • 发布于 2024-08-13
  • 13 次阅读
黄健
黄健

本文由 简悦 SimpRead 转码, 原文地址 blog.csdn.net

安全审计中有时会有

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

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

一、安装

  1. 下载 headers-more-nginx-module

下载地址
https://github.com/openresty/headers-more-nginx-module/tags

[root@localhost /]# cd /www/tools
[root@localhost tools]# wget https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.37.tar.gz
  1. 解压
    解压后会多出一个 headers-more-nginx-module-0.37 文件夹
[root@localhost tools]# tar -zxvf v0.37.tar.gz

# 进入
[root@localhost tools]# cd headers-more-nginx-module-0.37/

# 查看当前完整路径
[root@localhost headers-more-nginx-module-0.37]# pwd

# 复制装盘备用
/www/tools/headers-more-nginx-module-0.37

[root@localhost headers-more-nginx-module-0.37]# cd ..
  1. 查看当前系统 nginx 信息
// 查看当前nginx加载的模块
[root@localhost tools]# /www/server/nginx/sbin/nginx -V 
nginx version: nginx/1.22.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.1.1q  5 Jul 2022
TLS SNI support enabled
# 复制装盘备用
configure arguments: --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-openssl=/www/server/nginx/src/openssl --with-pcre=/www/server/nginx/src/pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --add-module=/www/server/nginx/src/ngx_http_substitutions_filter_module-master --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module
  1. 下载对应版本的 nginx

下载对应版本的 nginx

# 下载
[root@localhost tools]# wget http://nginx.org/download/nginx-1.22.1.tar.gz 

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

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

# 进入 nginx-1.22.1目录
[root@localhost tools]# cd nginx-1.22.1

# 先备份
[root@localhost nginx-1.12.1]# cp /www/server/nginx/sbin/nginx /www/server/nginx/sbin/nginx_old

# 编译
[root@localhost nginx-1.12.1]# ./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-openssl=/www/server/nginx/src/openssl --with-pcre=/www/server/nginx/src/pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --add-module=/www/server/nginx/src/ngx_http_substitutions_filter_module-master --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module --add-module=/www/tools/headers-more-nginx-module-0.37

# configure完成后进行make(如原本无nginx,make后还需make install)
[root@localhost nginx-1.12.1]# make
  1. 复制新的 nginx 到目录
[root@localhost nginx-1.12.1]# mv /www/server/nginx/sbin/nginx /www/server/nginx/sbin/nginx_bak
[root@localhost nginx-1.12.1]# cp objs/nginx /www/server/nginx/sbin/nginx
  1. 重新 nginx 生效

二、食用

修改 nginx 配置文件,增加代码块

# set the Server output header
 # 隐藏Server
 more_clear_headers 'Server';
 
 # 伪装Server
 more_set_headers 'Server: my-server';

 # set and clear output headers
 location /bar {
     more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
     more_set_headers -t 'text/plain text/css' 'Content-Type: text/foo';
     more_set_headers -s '400 404 500 503' -s 413 'Foo: Bar';
     more_clear_headers 'Content-Type';

     # your proxy_pass/memcached_pass/or any other config goes here...
 }

 # set output headers
 location /type {
     more_set_headers 'Content-Type: text/plain';
     # ...
 }

 # set input headers
 location /foo {
     set $my_host 'my dog';
     more_set_input_headers 'Host: $my_host';
     more_set_input_headers -t 'text/plain' 'X-Foo: bah';

     # now $host and $http_host have their new values...
     # ...
 }

 # replace input header X-Foo *only* if it already exists
 more_set_input_headers -r 'X-Foo: howdy';
标签: #软件开发 1171
相关文章

Nginx部署前端Vue项目 2024-09-26 17:57

在使用Nginx部署前端Vue项目时,我们主要关注的是如何高效地将静态资源(HTML、CSS、JavaScript、图片等)提供给客户端浏览器。Vue.js是一个流行的JavaScript框架,用于构建用户界面,而Nginx作为一个高性能的HTTP和反向代理服务器,非常适合用于静态资源的托管。以下将

Nginx+Tomcat负载均衡、反向代理 2024-09-28 15:11

目录 一、代理 1.概述 二、Nginx反向代理 1.七层反向代理 - 动静分离

Centos下安装nginx步骤解析 2024-08-19 16:06

最近研究LNMP,首先要在linux下配置nginx服务器,话不多说,上步骤 1、编译环境gcc g++ 开发库之类的需要提前装好   yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel 2、首先安装PC

Nginx 反向代理和负载均衡 2024-08-19 14:21

❤之前粗略的学习了一下nginx,也能够简单的进行使用,但时间长了难免就会出现遗忘,遇到命令啥的有时候还得去网上搜,索性就自己整理了一份,以后看起来也比较方便。有什么不对的地方还请大家多多指正。 目录 一、nginx 简介 1、nginx 概述 2、正向代理 3、反向代理 4、负载均衡<

nginx: [emerg] getpwnam(“nginx“) failed in /etc/nginx/nginx.conf:1 2024-08-13 17:01

本文由 简悦 SimpRead 转码, 原文地址 blog.csdn.net 在 Nginx 配置文件(/etc/nginx/nginx.conf)中出现错误信息 “ngin

隐藏nginx响应头中的server信息(HTTP服务器版本信息泄漏) 2024-08-13 13:40

本文由 简悦 SimpRead 转码, 原文地址 blog.csdn.net 安全审计中有时会有 漏洞名称 HTTP 服务器版本信息泄漏 漏洞描述 目标服务器

目录

IT 外包服务商

  • 意见投递
  • zyf6619

软件开发应用

主菜单

  • 首页
  • 软件开发
  • 计算机基础
  • Hello Halo
  • 新手必读
  • 关于本知识库
Copyright © 2024 your company All Rights Reserved. Powered by Halo.