隐藏nginx版本号
执行curl --head www.nginx.org获得如下输出:
HTTP/1.1 200 OK
Server:nginx/0.8.50
Date:Tue,07Sep201004:14:16GMT
Content-Type:text/html
Content-Length:11699
Last-Modified:Thu,02Sep201015:01:30GMT
Connection:keep-alive
Keep-Alive:timeout=15
Accept-Ranges: bytes这样,别人就知道你的服务器nginx版本是0.8.50。现在,我们要让它不显示nginx的版本号。
首先,修改nginx.conf文件,内容如下:
http { ......省略配置 sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; server_tokens off; .......省略配置 }
然后,找到fastcgi_params文件,我的是放在/usr/local/nginx/conf目录下,修改该文件,内容如下:
将 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 改为 fastcgi_param SERVER_SOFTWARE nginx;
nginx重新加载配置就完成了,404、501等页面都不会显示nginx版本了。
现在,再执行curl --head www.nginx.org获得如下输出:
HTTP/1.1 200 OK
Server:nginx
Date:Tue,07Sep201004:14:16GMT
Content-Type:text/html
Content-Length:11699
Last-Modified:Thu,02Sep201015:01:30GMT
Connection:keep-alive
Keep-Alive:timeout=15
Accept-Ranges:bytes
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29