Nginx隐藏修改版本信息

隐藏版本信息

编辑nginx.conf文件,在http区段加入server_tokens off;

[root@www ~]# curl -I http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.14.0
[root@www ~]# vi nginx.conf

 http {
         .................
        server_tokens off;
        ..................

[root@www ~]# curl -I http://127.0.0.1
HTTP/1.1 200 OK
Server: nginx

PS.该方法只是简单的把详细的版本号给去掉了,nginx字样还留着

修改版本信息

在安装编译之前修改nginx.h

[root@www ~]# vi src/core/nginx.h
...
#define nginx_version      1012002
#define NGINX_VERSION      "8.5"
#define NGINX_VER          "IIS/" NGINX_VERSION

根据需求自行更改,更改完后再重新编译

添加新评论