Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1058476
  • 博文数量: 321
  • 博客积分: 7872
  • 博客等级: 少将
  • 技术积分: 2120
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 09:06
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(1)

2015年(12)

2014年(17)

2013年(78)

2012年(15)

2011年(17)

2010年(67)

2009年(102)

2008年(11)

分类: LINUX

2012-07-18 10:25:44

Nginx默认是显示其版本号的,如:
[root@utoec ~]# curl -I
HTTP/1.1 302 Moved Temporarily
Server: nginx/0.8.51
Date: Wed, 13 Oct 2010 21:32:22 GMT
Content-Type: text/html
Content-Length: 161
Connection: keep-alive
Keep-Alive: timeout=15
Location:

之前爆出一些nginx版本存在可被攻击的漏洞,为保证web服务器的安全,将服务器软件信息隐藏是一种相对安全的作法。
1.编辑nginx配置文件:
[root@utoec conf]# vim nginx.conf
在http中加入 server_tokens off;
如:http {
……省略
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off; #加入的代码
…….省略
}
2、编辑php-fpm配置文件,如fastcgi.conf或fcgi.conf或(这个配置文件名也可以自定义的,根据具体文件名修改):
找到:
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为:
fastcgi_param SERVER_SOFTWARE nginx;
3、重新加载ngnix配置
nginx -s reload

隐藏php版本信息
1.编辑php配置文件
[root@localhost etc]# vim php.ini
找到expose_php = On
改为
expose_php = Off
2.重新加载php-fpm。

如隐藏nginx及php版本信息后:
[root@utoec ~]# curl -I
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 13 Oct 2010 21:51:13 GMT
Content-Type: text/html
Connection: keep-alive
Vary: Accept-Encoding

转自:

阅读(784) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~