修改nginx的http响应头server,以及真实ip模块、ssl模块、压缩模块的安装

修改nginx的http响应头server字段
修改源码 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 CRLF CRLF;
修改后:
static u_char ngx_http_server_string[] = "Server: X-Web" CRLF;
static u_char ngx_http_server_full_string[] = "Server: X-Web" CRLF;
static u_char ngx_http_server_build_string[] = "Server: X-Web" CRLF;

 

 

nginx安装https模块时,with-openssl 为openssl得源码路径,不是安装之后的路径
./configure --prefix=/opt/local/nginx --sbin-path=/opt/local/nginx/sbin/nginx --pid-path=/opt/logs/nginx/nginx.pid --error-log-path=/opt/logs/nginx/logs/error.log --http-log-path=/opt/logs/nginx/logs/access.log --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_gunzip_module --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-http_realip_module --with-openssl=/opt/soft/openssl-3.0.3

其中http_realip_module 为真实ip模块,http_gzip_static_module 为压缩模块

真实ip模块配置如下:

real_ip_header X-Forwarded-For;
set_real_ip_from x.x.x.x;

其中x.x.x.x 为来源ip,比如waf的ip

 

查看日志:

tail -200f 8002_access.log |cut -d " " -f 1,4,7,9

posted @ 2022-06-21 08:25  青木流水  阅读(526)  评论(0编辑  收藏  举报