下载 nginx-1.19.1.tar.gz
操作步骤:
[root@Test ~]# tar -xzvf nginx-1.19.1.tar.gz
修改ngx_http_header_filter_module.c 文件
[root@Test ~]# vim nginx-1.19.1/src/http/ngx_http_header_filter_module.c
需要修改:
static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;
修改成:
static u_char ngx_http_server_string[] = "Server: unknow" CRLF;
static u_char ngx_http_server_full_string[] = "Server: unknow" CRLF;
static u_char ngx_http_server_build_string[] = "Server: unknow" CRLF;
重新编译:
./configure --prefix=/usr/local/nginx && make && make install
编译报错信息:
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
解决方法:
[root@Test ~]# yum -y install openssl openssl-devel
注:非root用户要启动1024下的端口
setcap cap_sys_admin,cap_net_bind_service,cap_sys_resource+ep /usr/local/nginx/sbin/nginx
重启 nginx
[root@Test ~]# systemctl restart nginx