当前位置: > Linux服务器 > nginx >

让 Nginx 关闭版本显示信息

时间:2016-10-06 19:22来源:linux.it.net.cn 作者:IT
Nginx 会在 http 头,或者出现错误页的时候会有醒目的版本号提示。
为了安全,可以关闭这些信息。
方法很简单,只需在 nginx.conf 的 http {  里头加入 server_tokens 的参数


例如:

 
  1. http {  
  2. include       mime.types;  
  3. default_type  application/octet-stream;  
  4. server_tokens off;     #关闭版本显示  
  5. client_header_timeout       3m;  
  6. client_body_timeout         3m;  
  7. send_timeout                3m;  


 
使用 curl 工具测试结果如下:

 
  1. HTTP/1.1 301 Moved Permanently  
  2. Server: nginx  
  3. Date: Fri, 11 Dec 2009 01:47:53 GMT  
  4. Content-Type: text/html  
  5. Content-Length: 178  
  6. Connection: keep-alive  
  7. Keep-Alive: timeout=20  
  8. Location: http://www.汪翰翔.cn/index  
  9.  

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容