[英]How to remove http header from http response fields Liferay-Portal, Server?
與liferay合作,總是說門戶網站作為回應:
Liferay-Portal:Liferay Portal Community Edition 6.1.0 CE (Paton / Build 6100 / January 6, 2012)
Server:GlassFish Server Open Source Edition 3.1.1
我該如何刪除這些信息?
無法刪除添加到HttpServletResponse
對象的標頭。 解決此問題的唯一方法是使用Filter
Wrapping the HttpServletResponse
對象並吃掉想要忽略的標頭。
這是要使用的示例代碼,
public class EatHeadersFilters implements Filter
{
private List<String> headers;
public void init(FilterConfig filterConfig) throws ServletException
{
String headersString = filterConfig.getInitParameter("headers");
String[] strings = headersString.split(",");
headers = Arrays.asList(strings);
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException
{
filterChain.doFilter(request,
new HttpServletResponseWrapper((HttpServletResponse) response){
public void addHeader(String headerName, String headerValue)
{
if(!headers.contains(headerName)){
super.addHeader(headerName, headerValue);
} else {
//eat the header
}
}
});
}
public void destroy()
{
}
}
Ramesh是正確的,但這是純粹的Servlet實現。 請檢查com.liferay.portal.kernel.servlet.WrapHttpServletResponseFilter
接口。 它由同一目的提供。 它將在Portlet上下文中工作。
您可以在portal-ext.properties中使用以下鍵來僅顯示App名稱和版本(例如社區)
http.header.version.verbosity=partial
這不應該顯示特定的版本。
原始資源發現於http://arunkumarsrm.blogspot.com/2012/11/liferay-611-ga2-application-security.html
此外,您可以進一步檢查以下門票,以熟悉提供的補丁(我還沒有嘗試過)
http://issues.liferay.com/browse/LPS-2748
http://issues.liferay.com/browse/LPS-9011
* UPD:*實際上您可以使用以下選項完全禁用服務器信息:
# portal-ext.properties:
http.header.version.verbosity=Liferay Portal Community Edition
並在/tomcat-7.0.27/conf/server.xml中進行以下配置
<Connector
URIEncoding="UTF-8"
connectionTimeout="20000"
port="8080"
protocol="HTTP/1.1"
redirectPort="8443"
server="My Server!"
/>
資源: http : //tech-annex.blogspot.com/2013/01/hidding-server-signaturebanner.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.