源码编译nginx

vim /usr/local/nginx/conf/nginx.conf

在http加入server_tokens off;

nginx 隐藏版本号_源码编译

nginx -s reload

nginx 隐藏版本号_nginx_02


[root@localhost logs]# /usr/local/nginx/sbin/nginx -g

"daemon off;"

现在当前nginx在前端运行,

输入ctrl +c,则nginx就退出了。

可以使用ctrl +z放置后台运行。

二,根源上修改nginx版本号。

这个比较彻底,一般是安装之前就修改源码,如安装过的,就要修改源码重新编译。一般修改三个地方:

1,修改src/core/nginx.h(Nginx内部名称的)

#define NGINX_VERSION      "1.12.0"#define NGINX_VER          "nginx/" NGINX_VERSION

2,修改src/http/ngx_http_header_filter_module.c(HTTP ResponseHeader)

static u_char ngx_http_server_string[] = "Server: nginx" CRLF

3,修改src/http/ngx_http_special_response.c(修改错误页的底部Footer)

static u_char ngx_http_error_tail[] = 下的nginx信息

修改完这些以后编译安装,或者重新编译。nginx版本信息则彻底修改。