查看nginx | apache | php | tengine | tomcat版本的信息以及如何隱藏版本信息

昨天配置nginx的時候說道隱藏版本信息的問題,今天就羅列一下

要操做的信息列表

  • nginx版本信息查詢及隱藏php

  • Apache版本信息查詢及隱藏html

  • php版本信息查詢及隱藏nginx

  • tengine版本信息查詢及隱藏apache

  • tomcat版本信息查詢及隱藏vim

詳細操做步驟

1.一、nginx版本信息查詢

      [root@zhuima_nginx ~]# nginx -vnginx version: nginx/1.6.0

1.二、nginx編譯配置參數查詢

       [root@zhuima_nginx ~]# nginx -V
       nginx version: nginx/1.6.0
       built by gcc 4.4.7 20120313 (Red Hat4.4.7-4) (GCC) TLS SNI support enabledconfigure arguments:       --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module        
       --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

1.三、客戶端查看nginx的Response Header信息

      [root@zhuima_client ~]# curl -I       HTTP/1.1 200 OKServer: nginx/1.6.0
      Date: S      at, 19 Jul 2014 02:18:54 
      GMTContent-Type: text/html
      Content-Length: 16412
      Last-Modified: Mon, 07       Jul 2014 05:25:22 G      MT
      Connection: keep-alive
      Vary: Accept-Encoding
      ETag: "53ba2f42-401c"
      Accept-Ranges: bytes

spacer.gif

1.四、如何隱藏nginx的Response Header中返回的版本號信息

  • 修改nginx配置文件,在全局配置中添加server_tokens off; 這一行tomcat

  1. [root@zhuima_nginx ~]# 服務器

  2. [root@zhuima_nginx  ~]# sed -n '/server_tokens/p' /usr/local/nginx/conf/nginx.confapp

  3. server_tokens off;              # 在nginx全局配置文件中添加這行便可curl

  4. [root@zhuima_nginx  ~]#ide

重啓nginx服務而後客戶端驗證效果

  1. [root@zhuima_client ~]# curl -I http://218.244.xxx.xxx

  2. HTTP/1.1 200 OK

  3. Server: nginx

  4. Date: Sat, 19 Jul 2014 02:33:11 GMT

  5. Content-Type: text/html

  6. Content-Length: 16412

  7. Last-Modified: Mon, 07 Jul 2014 05:25:22 GMT

  8. Connection: keep-alive

  9. Vary: Accept-Encoding

  10. ETag: "53ba2f42-401c"

  11. Accept-Ranges: bytes

二、Apache版本信息查詢及隱藏

2.一、apache版本信息查詢

  • apache版本信息查詢

  1. [root@zhuima_httpd ~]# apachectl -v

  2. Server version: Apache/2.2.15 (Unix)

  3. Server built:   Apr  3 2014 23:56:16

  4. [root@zhuima_httpd ~]#

apache編譯參數查詢

  1. [root@zhuima_httpd ~]# apachectl -V

  2. Server version: Apache/2.2.15 (Unix)

  3. Server built:   Apr  3 2014 23:56:16

  4. Server's Module Magic Number: 20051115:25

  5. Server loaded:  APR 1.3.9, APR-Util 1.3.9

  6. Compiled using: APR 1.3.9, APR-Util 1.3.9

  7. Architecture:   64-bit

  8. Server MPM:     Prefork

  9. threaded:     no

  10.  forked:     yes (variable process count)

  11. Server compiled with....

  12. -D APACHE_MPM_DIR="server/mpm/prefork"

  13. -D APR_HAS_SENDFILE

  14. -D APR_HAS_MMAP

  15. -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)

  16. -D APR_USE_SYSVSEM_SERIALIZE

  17. -D APR_USE_PTHREAD_SERIALIZE

  18. -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT

  19. -D APR_HAS_OTHER_CHILD

  20. -D AP_HAVE_RELIABLE_PIPED_LOGS

  21. -D DYNAMIC_MODULE_LIMIT=128

  22. -D HTTPD_ROOT="/etc/httpd"

  23. -D SUEXEC_BIN="/usr/sbin/suexec"

  24. -D DEFAULT_PIDLOG="run/httpd.pid"

  25. -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"

  26. -D DEFAULT_LOCKFILE="logs/accept.lock"

  27. -D DEFAULT_ERRORLOG="logs/error_log"

  28. -D AP_TYPES_CONFIG_FILE="conf/mime.types"

  29. -D SERVER_CONFIG_FILE="conf/httpd.conf"

  30. [root@zhuima_httpd ~]#

2.二、apache版本信息隱藏

  • 客戶端驗證apahce的Response Headers頭信息

  1. [root@zhuima_client ~]# curl -I http://192.168.xxx.xxx

  2. HTTP/1.1 403 Forbidden

  3. Date: Sat, 19 Jul 2014 02:41:02 GMT

  4. Server: Apache/2.2.15 (CentOS)

  5. Accept-Ranges: bytes

  6. Content-Length: 5039

  7. Connection: close

  8. Content-Type: text/html; charset=UTF-8

spacer.gif

  • 在Apache配置文件中添加ServerTokens ProductOnly

  1. #ServerTokens OS             # 註釋掉改行

  2. Servertokens off             # 添加這行屏蔽apache版本信息    

  3. ServerSignature Off          # 添加這行屏蔽系統信息

重啓httpd服務以後客戶端再次驗證

  1. [root@zhuima_client ~]# curl -I http://192.168.xxx.xxx

  2. HTTP/1.1 403 Forbidden

  3. Date: Sat, 19 Jul 2014 02:47:21 GMT

  4. Server: Apache

  5. Accept-Ranges: bytes

  6. Content-Length: 5039

  7. Connection: close

  8. Content-Type: text/html; charset=UTF-8

三、略


四、tengine版本信息查詢及隱藏

4.一、tengine版本信息查詢

這裏爲何要把tengine單獨拿出來講事呢,初裝tengine的童鞋確定會有點迷茫,爲毛tengine會顯示出那麼多的系統版本信息,除此以外其餘操做和nginx同樣,這裏僅說下nginx版本的隱藏相關

顯示的信息有:

  • Server----->服務器名稱

  • tengine版本信息

  • 服務器端的時間
    spacer.gif有圖爲證:

    wKiom1PKB3uhg1fzAAPptCWO6Vk888.jpg

4.二、tengine版本信息隱藏

  • 在tengine配置文件中添加下面三項便可

  1. server_tag off;

  2. server_info off;

  3. server_tokens off;

  • 重啓tengine服務再次進行驗證

    wKioL1PKDdrRrTtTAAOYZuxkuVU771.jpg

五、tomcat版本信息查詢及隱藏

5.一、tomcat版本信息查詢

  • tomcat版本信息查詢(新接手環境的時候頗有必要查看的)

  1. [root@zhuima_tomcat ~]$ catalina.sh version

  2. ...............................

  3. Server version: Apache Tomcat/7.0.42

  4. Server built:   Jul 2 2013 08:57:41

  5. Server number:  7.0.42.0

  6. OS Name:        Linux

  7. OS Version:     2.6.32-431.el6.x86_64

  8. Architecture:   amd64

  9. JVM Version:    1.7.0_09-b05

  10. JVM Vendor:     Oracle Corporation

客戶端驗證tomcat版本信息

5.二、tomcat版本信息隱藏

  • 隱藏tomcat版本信息

    • 到apache-tomcat安裝目錄下的lib子文件夾,找到catalina.jar這包,並進行解

    • 解壓以後進度到org/catalina/apache/util/目錄下,編輯ServerInfo.properties

    • vim /path/tomcat/lib/org/apache/catalina/util/ServerInfo.properties

    • 來張修改先後的對比圖吧
      spacer.gifwKiom1PKB9iRw9IFAAlhGbthKxQ603.jpg

  • 再次驗證頁面顯示信息
    spacer.gifwKioL1PKCQnRZgk3AAFk3xENojY471.jpg



總結:

  • 新的環境中儘量多用help指令查看老的環境的部署

  • 操做以前儘量作的備份,要否則你懂得後果的

  • 最主要的仍是要了解並掌握大多數經常使用服務,要否則也是乾瞪眼

  • 本篇文章純屬扯淡,沒啥技術含量

  • 打完收工

相關文章
相關標籤/搜索