Changing Tomcat server name in response header, is

2019-05-08 06:03发布

When a http request from a browser is made, typically the server container will send along in the header what server it was.

For tomcat it sends

   Server:Apache-Coyote/1.1

I know I can overwrite this header, for each request, but there is also the case for websockets and potentially other connections.

So, is there a way to change this at the tomcat configuration level?

2条回答
Root(大扎)
2楼-- · 2019-05-08 06:41

Programmatically, given a org.apache.catalina.connector.Connector, it's: connector.setAttribute("server", "Something")

Caution: Coyote ignores the server name if it's an empty string.

查看更多
乱世女痞
3楼-- · 2019-05-08 06:56

I just found this after posting the question:

Add this to server.xml in tomcat config folder.

<Connector port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443"
                   server="MYSERVER"
                />

seems to work.

Restart server.

查看更多
登录 后发表回答