随笔记载,欢迎指正:

修改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 "<hr><center>LLSERVER</center>" 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