nginx安全之headers-more-nginx-module模块
概述:headers-more-nginx-module模块可以帮助nginx自定义请求响应的头,在很多情况下隐藏和修改头,能在一定程度上避免安全攻击等问题,目前阿里云的负载均衡就有类似的功能,下面我们来看看headers-more-nginx-module在淘宝tengine上的编译使用。测试系统为centos7, tengine版本tengine-2.3.2,可以去tengine官网下载对应版本即可。
1、安装必要组件
首先我们需要增加系统对正则和ssl支持的模块,如下:
#yum install -y openssl-devel pcre-devel
2、安装tengine,headers-more-nginx-module-0.33支持
#cd /usr/local/src/
#tar -zxvf headers-more-nginx-module-0.33.tar.gz
#tar -zxvf tengine-2.3.2.tar.gz
#useradd nginxuser
#./configure --user=nginxuser--group=nginxuser--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--add-module=/usr/local/src/headers-more-nginx-module-0.33
#cd /usr/local/nginx/sbin/
#./nginx
3、使用headers-more-nginx-module
http {
......
more_set_headers "Server:myWEBSERVER";
more_set_headers "X-Powered-By:myOS";
more_clear_headers "Product:";
......
}
说明:我们可以使用more_set_headers指令来替换或增加指定的头信息,使用more_clear_headers指令来擦除掉指定的头信息。
本文标签: nginx 安全
内容版权声明:【蓝色网居】部分资源来源于网络,如有侵犯您的所有权,请随时告知我们,我们将立即删除!感谢配合!
【手机扫一扫查看文本】
cookie 404 日志分析 白名单 案例分析 错误页 防IP 模糊匹配 编译安装 ip白名单 防IP恶意 try_files 参数重写 pass_proxy的使 统计 ngx_cache_pu 恶意请求 运算 自启动 404自定义 与(and) geoIP模块 请求频率 扫描访问 跳转rewrite apache geoip 跳转 后台管理 $http_host

