Nginx默认是显示版本号的,如:php
[root@hadooptest ~]# curl -I www.nginx.org HTTP/1.1 200 OK Server: nginx/0.8.44 Date: Tue, 13 Jul 2010 14:05:11 GMT Content-Type: text/html Content-Length: 8284 Last-Modified: Tue, 13 Jul 2010 12:00:13 GMT Connection: keep-alive Keep-Alive: timeout=15 Accept-Ranges: bytes
这样就给人家看到你的服务器nginx版本是0.8.44,前些时间暴出了一些Nginx版本漏洞,就是说有些版本有漏洞,而有些版本没有。这样暴露出来的版本号就容易变成攻击者可利用的信息。因此,从安全的角度来讲,隐藏版本号会相对安全些!
那nginx版本号能够隐藏不?其实能够的,看下面个人步骤:html
一、进入nginx配置文件的目录(此目录根据安装时决定),用vim编辑打开node
vim nginx.confnginx
在http {—}里加上server_tokens off; 如:vim
http { ……省略 sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; server_tokens off; …….省略 }
二、编辑php-fpm配置文件,如fastcgi.conf或fcgi.conf(这个配置文件名也能够自定义的,根据具体文件名修改):
找到:安全
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改成:服务器
fastcgi_param SERVER_SOFTWARE nginx;
三、从新加载nginx配置:curl
# /etc/init.d/nginx reload
这样就彻底对外隐藏了nginx版本号了,就是出现40四、501等页面也不会显示nginx版本。tcp
修改后内容是:php-fpm
[root@hadooptest ~]# curl -I www.nginx.org HTTP/1.1 200 OK Server: nginx Date: Tue, 13 Jul 2010 14:05:11 GMT Content-Type: text/html Content-Length: 8284 Last-Modified: Tue, 13 Jul 2010 12:00:13 GMT Connection: keep-alive Keep-Alive: timeout=15 Accept-Ranges: bytes