隐藏JSF应用中的HTTP Header信息

 

对于JSF的应用,你可能会在HTTP的头信息中看到这样的字样:

Server : Apache/2.0.61 (Unix)
X-Powered-By : JSF/1.2

让用户知道这些消息没有太大意义,而且可能造成安全漏洞。需要屏蔽的话可以参考以下步骤:

隐藏Server信息:在apache里控制的,在httpd.conf里加入一行

    ServerTokens Prod

隐藏X-Powered-By:在web.xml中加入:

 

view plain copy to clipboard print ?
  1. <context-param>  
  2.     <param-name>com.sun.faces.sendPoweredByHeaderparam-name>  
  3.     <param-value>falseparam-value>  
  4. context-param>  
com.sun.faces.sendPoweredByHeader false

 

对于JBoss,需要找到这个文件:/server/default/deploy/jboss-web.deployer/conf/web.xml,然后加入以下代码:

 

view plain copy to clipboard print ?
  1. <filter>  
  2.       <filter-name>CommonHeadersFilterfilter-name>  
  3.       <filter-class>org.jboss.web.tomcat.filters.ReplyHeaderFilterfilter-class>  
  4.       <init-param>  
  5.          <param-name>X-Powered-Byparam-name>  
  6.          <param-value>Servlet 2.4; JBoss-4.2.0.GA (build:   
  7. SVNTag=JBPAPP_4_2_0_GA date=200706281411)/Tomcat-5.5param-value>  
  8.       init-param>  
  9.    filter>  
  10. ↓   
  11.    <filter>  
  12.       <filter-name>CommonHeadersFilterfilter-name>  
  13.       <filter-class>org.jboss.web.tomcat.filters.ReplyHeaderFilterfilter-class>  
  14.    filter>  
CommonHeadersFilter org.jboss.web.tomcat.filters.ReplyHeaderFilter X-Powered-By Servlet 2.4; JBoss-4.2.0.GA (build: SVNTag=JBPAPP_4_2_0_GA date=200706281411)/Tomcat-5.5 CommonHeadersFilter org.jboss.web.tomcat.filters.ReplyHeaderFilter

 

 

 

转载自 http://www.ondev.net/post/show/585

你可能感兴趣的:(编程相关)