隐藏nginx版本
1.首先查看下本机nginx版本信息为nginx1.18
[root@scyun ~]
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Thu, 17 Dec 2020 08:12:28 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 17 Dec 2020 08:10:03 GMT
Connection: keep-alive
ETag: "5fdb125b-264"
Accept-Ranges: bytes
2.隐藏nginx版本号
[root@scyun ~]
server_tokens off;
3.重新加载文件验证
[root@scyun ~]
[root@scyun ~]
curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 17 Dec 2020 08:20:32 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 17 Dec 2020 08:10:03 GMT
Connection: keep-alive
ETag: "5fdb125b-264"
Accept-Ranges: bytes
修改nginx版本(源码部署)
1.修改源码部署的nginx需要重新编译,需修改源文件代码
[root@scyun nginx-1.18.0]
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
[root@scyun nginx-1.18.0]
[root@scyun nginx-1.18.0]
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx
[root@scyun nginx-1.18.0]
[root@scyun nginx-1.18.0]
[root@scyun nginx-1.18.0]
2.验证更改版本号
[root@scyun nginx-1.18.0]
curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: SCSW/2.18.0
Date: Thu, 17 Dec 2020 08:40:00 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 17 Dec 2020 08:10:03 GMT
Connection: keep-alive
ETag: "5fdb125b-264"
Accept-Ranges: bytes