Nginx 会在 http 头,或者出现错误页的时候会有醒目的版本号提示。
为了安全,可以关闭这些信息。
方法很简单,只需在 nginx.conf 的 http { 里头加入 server_tokens 的参数
例如:
使用 curl 工具测试结果如下:
如果想把 Server 所显示的名称也修改,可以参阅:http://www.oschina.net/bbs/thread/1568?lp=1
为了安全,可以关闭这些信息。
方法很简单,只需在 nginx.conf 的 http { 里头加入 server_tokens 的参数
例如:
http {
include mime.types;
default_type application/octet-stream;
server_tokens off; #关闭版本显示
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;使用 curl 工具测试结果如下:
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 11 Dec 2009 01:47:53 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Keep-Alive: timeout=20
Location: http://www.汪翰翔.cn/index如果想把 Server 所显示的名称也修改,可以参阅:http://www.oschina.net/bbs/thread/1568?lp=1
本文介绍如何通过配置Nginx来隐藏其版本信息,增强服务器安全性。仅需在nginx.conf文件中设置server_tokens off即可实现。此外还提供了一个使用curl工具测试隐藏效果的例子。
1630

被折叠的 条评论
为什么被折叠?



