How to disable remote shutdown in Tomcat
Examples:
- change the port number from default to different one (not recommended)
- change the shutdown command (partially recommended)
- change port number to -1 (recommended)
$CATALINA_HOME/conf/server.xml<Server port="8005" shutdown="SHUTDOWN">
<Server port="8005" shutdown="SHUTDOWN">
<Server port="8008" shutdown="SECRETCOMMAND">
[me@me ~]$ telnet 192.168.1.3 8005
Trying 192.168.1.3...
Connected to 192.168.1.3.
Escape character is '^]'.
SHUTDOWN
Connection closed by foreign host.
|
WARNING: StandardServer.await: Invalid command 'SHUTDOWN' received
|
EXAMPLE 2:
Change the settings in the server.xml file from:
<Server port="8005" shutdown="SHUTDOWN">To
<Server port="8001" shutdown="SHUTDOWN">From now on only SHUTDOWN command issued on port 8001 (if not used by other application) will shutdown the instance. Port 8005 will not be used by this instance.
Result:
[me@me ~]$ telnet 192.168.1.3 8005
Trying 192.168.1.3...
telnet: connect to address 192.168.1.3: Connection refused
|
EXAMPLE 3 (recommended):
Change the settings in the server.xml file from:
<Server port="8005" shutdown="SHUTDOWN">To
<Server port="-1" shutdown="SHUTDOWN">This will disable SHUTDOWN service/ command for good :)
Result:
[me@me ~]$ telnet 192.168.1.3 8005
Trying 192.168.1.3...
telnet: connect to address 192.168.1.3: Connection refused
|