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

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

要操作的信息列表

  • nginx版本信息查詢及隱藏

  • Apache版本信息查詢及隱藏

  • php版本信息查詢及隱藏

  • tengine版本信息查詢及隱藏

  • tomcat版本信息查詢及隱藏

詳細操作步驟

1.1、nginx版本信息查詢

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

1.2、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.3、客戶端查看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.4、如何隱藏nginx的Response Header中返回的版本號信息

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

  1. [root@zhuima_nginx ~]#

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

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

  4. [root@zhuima_nginx  ~]#

重啓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

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

2.1、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.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

3、略


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

4.1、tengine版本信息查詢

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

顯示的信息有:

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

  • tengine版本信息

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

    wKiom1PKB3uhg1fzAAPptCWO6Vk888.jpg

4.2、tengine版本信息隱藏

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

  1. server_tag off;

  2. server_info off;

  3. server_tokens off;

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

    wKioL1PKDdrRrTtTAAOYZuxkuVU771.jpg

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

5.1、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.2、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指令查看老的環境的部署

  • 操作之前儘可能做的備份,要不然你懂得後果的

  • 最主要的還是要了解並掌握大多數常用服務,要不然也是乾瞪眼

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

  • 打完收工


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章