昨天配置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
1.4、如何隱藏nginx的Response Header中返回的版本號信息
修改nginx配置文件,在全局配置中添加server_tokens off; 這一行
[root@zhuima_nginx ~]#
[root@zhuima_nginx ~]# sed -n '/server_tokens/p' /usr/local/nginx/conf/nginx.conf
server_tokens off; # 在nginx全局配置文件中添加這行即可
[root@zhuima_nginx ~]#
重啓nginx服務然後客戶端驗證效果
[root@zhuima_client ~]# curl -I http://218.244.xxx.xxx
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 19 Jul 2014 02:33:11 GMT
Content-Type: text/html
Content-Length: 16412
Last-Modified: Mon, 07 Jul 2014 05:25:22 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "53ba2f42-401c"
Accept-Ranges: bytes
2、Apache版本信息查詢及隱藏
2.1、apache版本信息查詢
apache版本信息查詢
[root@zhuima_httpd ~]# apachectl -v
Server version: Apache/2.2.15 (Unix)
Server built: Apr 3 2014 23:56:16
[root@zhuima_httpd ~]#
apache編譯參數查詢
[root@zhuima_httpd ~]# apachectl -V
Server version: Apache/2.2.15 (Unix)
Server built: Apr 3 2014 23:56:16
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@zhuima_httpd ~]#
2.2、apache版本信息隱藏
客戶端驗證apahce的Response Headers頭信息
[root@zhuima_client ~]# curl -I http://192.168.xxx.xxx
HTTP/1.1 403 Forbidden
Date: Sat, 19 Jul 2014 02:41:02 GMT
Server: Apache/2.2.15 (CentOS)
Accept-Ranges: bytes
Content-Length: 5039
Connection: close
Content-Type: text/html; charset=UTF-8
在Apache配置文件中添加ServerTokens ProductOnly
#ServerTokens OS # 註釋掉改行
Servertokens off # 添加這行屏蔽apache版本信息
ServerSignature Off # 添加這行屏蔽系統信息
重啓httpd服務之後客戶端再次驗證
[root@zhuima_client ~]# curl -I http://192.168.xxx.xxx
HTTP/1.1 403 Forbidden
Date: Sat, 19 Jul 2014 02:47:21 GMT
Server: Apache
Accept-Ranges: bytes
Content-Length: 5039
Connection: close
Content-Type: text/html; charset=UTF-8
3、略
4、tengine版本信息查詢及隱藏
4.1、tengine版本信息查詢
這裏爲什麼要把tengine單獨拿出來說事呢,初裝tengine的童鞋肯定會有點迷茫,爲毛tengine會顯示出那麼多的系統版本信息,除此之外其他操作和nginx一樣,這裏僅說下nginx版本的隱藏相關
顯示的信息有:
4.2、tengine版本信息隱藏
在tengine配置文件中添加下面三項即可
server_tag off;
server_info off;
server_tokens off;
重啓tengine服務再次進行驗證
5、tomcat版本信息查詢及隱藏
5.1、tomcat版本信息查詢
tomcat版本信息查詢(新接手環境的時候很有必要查看的)
[root@zhuima_tomcat ~]$ catalina.sh version
...............................
Server version: Apache Tomcat/7.0.42
Server built: Jul 2 2013 08:57:41
Server number: 7.0.42.0
OS Name: Linux
OS Version: 2.6.32-431.el6.x86_64
Architecture: amd64
JVM Version: 1.7.0_09-b05
JVM Vendor: Oracle Corporation
客戶端驗證tomcat版本信息
5.2、tomcat版本信息隱藏
隱藏tomcat版本信息
總結:
新的環境中儘可能多用help指令查看老的環境的部署
操作之前儘可能做的備份,要不然你懂得後果的
最主要的還是要了解並掌握大多數常用服務,要不然也是乾瞪眼
本篇文章純屬扯淡,沒啥技術含量
打完收工