Tomcat Response Header Fields

谁都会走 提交于 2019-12-25 08:09:22

问题


Is there a way to not displaying the header fileds of http response.

For example :

HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed

The field Server may be a bad pratice when it is shown. I thought there were a production mode for tomcat with an ability to hide some header fields.

Thanks.


回答1:


In your server.xml file, add server="___" to the connector to change the header name. I believe just "" will remove the header or send a blank, but I'm not positive.

So your connectors will look something like this:

<Connector port="8080"
           protocol="HTTP/1.1" 
           connectionTimeout="20000"
           server="Not Tomcat">

Note that I had problems when changing this on a development machine. I decided it was a problem with Netbeans looking for the default header and complaining about the server not running when the server setting was anything but the default. But it works great on the production servers.

But... It looks like you're using an Apache httpd server, since the default Tomcat server header is "Apache-Coyote/1.1", at least for 8.0.38. I don't know if changing that in the Tomcat back end will make it past the Apache server.



来源:https://stackoverflow.com/questions/40845984/tomcat-response-header-fields

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!