NGINX服务安全
禁用模块
隐藏版本信息
限制并发
拒绝非法请求
防止buff溢出
nginx是模块化设计
启用模块需要 --with 加载模块
禁用模块需要使用 --without 禁用模块
因为好多模块都是默认安装的,所以不需要的模块但是又自动安装需要禁用
安装nginx时 需要安装依赖,不同的环境需要安装不同的依赖关系
]# yum -y install gcc pcre-devel zlib-devel
禁用模块
为了nginx的安全需要禁用http_autoindex_module 模块 和 http_ssi_module模块
禁用模块在编译安装的时候进行
autoindex 禁用自动索引文件目录模块
]# ./configure --without-http_autoindex_module --without-http_ssi_module
]# make && make install
隐藏版本信息
linux中一切皆文件,一切皆命令, nginx的版本信息就写在文件ngx_http_header_filter_module.c中 在文件中修改源代码,实现隐藏版本信息的功能
在配置文件下手动添加,
[root@localhost nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf
html {
server_tokens off;
修改源代码文件
]# vim src/http/ngx_http_header_filter_module.c
49-51行 默认
static u_char ngx_http_server_string[]