4

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
mjs
  • 21,431
  • 31
  • 118
  • 200

3 Answers3

2

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.

mjs
  • 21,431
  • 31
  • 118
  • 200
  • this on its own isnt very useful. post the name of the file where you add this & any other steps needed, e.g. restart – Reimeus Apr 16 '16 at 13:36
1

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.

Raul Santelices
  • 1,030
  • 11
  • 17
  • Note, that this won't apply for websockets header, which also has to make a similar call. – mjs Mar 29 '18 at 14:26
0

GoTo your tomcat (server.xml) installation path exa:- C:/[Apache-Tomcat-Installation-Directory]/conf/server.xml

find:- Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
enableLookups="false" redirectPort="8443"

add:- server="Any Server Name" inside the above tag. for safety purpose take a backup of xml file.

K D
  • 287
  • 3
  • 10