xxuyuan 2010-10-14
执行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