千家信息网

nginx 安全笔记 (修改nginx的header信息和错误显示版本号)

发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,随笔记载,欢迎指正:修改nginx的header信息和错误显示版本号1.隐藏版本号:nginx的配置文件nginx.conf找到http栏目加入:server_tokens off;2.修改显示ngi
千家信息网最后更新 2026年10月31日nginx 安全笔记 (修改nginx的header信息和错误显示版本号)

随笔记载,欢迎指正:

修改nginx的header信息和错误显示版本号

1.隐藏版本号:

nginx的配置文件nginx.conf找到http栏目加入:

server_tokens off;

2.修改显示nginx的名称

需要修改源码文件:

/opt/soft/nginx-1.2.0/src/http/ngx_http_special_response.c

vi /opt/soft/nginx-1.2.0/src/http/ngx_http_special_response.c

找到29行:

29 "


LLSERVER
" CRLF ##修改成需要的名称

/opt/soft/nginx-1.2.0/src/http/ngx_http_header_filter_module.c

vi /opt/soft/nginx-1.2.0/src/http/ngx_http_header_filter_module.c

找到49和50行:

static char ngx_http_server_string[] = "Server: LLSERVER" CRLF;

static char ngx_http_server_full_string[] = "Server: LLSERVER " NGINX_VER CRLF;

修改成相应的名称即可

再次访问的时候:

404 Not Found


LLSERVER


0