Nginx更改源码隐藏软件名和版本号

来源:互联网 发布:淘宝评价怎么看五星 编辑:程序博客网 时间:2024/05/16 16:00

通过源码的方式安装Nginx,修改源码文件,隐藏Nginx的名字与版本号。
这里拿IIS举例,当然,也可以修改成别的名字,比如foo

tar zxvf nginx-1.10.2.tar.gzcd nginx-1.10.2/vim src/core/nginx.h

【nginx.h】

//此行修改的是你想要的版本#define NGINX_VERSION      "1.10.2"     //第13行//此行修改的是你想修改的软件名称#define NGINX_VER          "nginx/" NGINX_VERSION  //第14行

修改上面的信息,即可更改nginx显示版本。例如:

#define NGINX_VERSION      "7.0"#define NGINX_VER          "IIS/" NGINX_VERSION

【ngx_http_header_filter_module.c】

 vim src/http/ngx_http_header_filter_module.c

修改前:

static char ngx_http_server_string[] = "Server: nginx" CRLF;  //第49行

修改后:

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

【ngx_http_special_response.c】

vim src/http/ngx_http_special_response.c

修改前:

static u_char ngx_http_error_tail[] =     //第29行"<hr><center>nginx</center>" CRLF"</body>" CRLF"</html>" CRLF;

修改后:

static u_char ngx_http_error_tail[] ="<hr><center>IIS</center>" CRLF"</body>" CRLF"</html>" CRLF;
原创粉丝点击