常见配置详解
端口8005/tcp 配置管理
在conf/server.xml 有以下内容
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
</Server>
<Server port="8005" shutdown="SHUTDOWN">
8005是Tomcat的管理端口,默认监听在127.0.0.1上。无需认验,就可发送SHUTDOWN这个字符串,tomcat接收到后就会关闭此Server。这个管理功能建议禁用,改shutdown为一串猜不出的字符串,比如以下示例
<Server port="8005" shutdown="44ba3c71d57f494992641b258b965f28">
范例:修改8005/tcp端口管理命令
[root@centos8 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 100 *:8009 *:*
[root@centos8 ~]#telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SHUTDOWN
Connection closed by foreign host.
[root@centos8 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@centos8 tomcat]#vim conf/server.xml
<Server port="8005" shutdown="magedu">
[root@centos8 tomcat]#systemctl start tomcat
[root@centos8 tomcat]#telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SHUTDOWN
Connection closed by foreign host.
[root@centos8 tomcat]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 *:8080 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 1 [::ffff:127.0.0.1]:8005 *:*
LISTEN 0 100 *:8009 *:*
[root@centos8 tomcat]#telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
magedu
Connection closed by foreign host.
[root@centos8 tomcat]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@centos8 tomcat]#
其它配置
conf/server.xml中可以配置service,connector, Engine,Host等
- service配置
一般情况下,一个Server实例配置一个Service,name属性相当于该Service的ID。
<Service name="Catalina">
- 连接器配置
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
redirectPort,如果访问HTTPS协议,自动转向这个连接器。但大多数时候,Tomcat并不会开启HTTPS,因为Tomcat往往部署在内部,HTTPS性能较差
- 引擎配置
<Engine name="Catalina" defaultHost="localhost">
- defaultHost 配置
defaultHost指向内部定义某虚拟主机。缺省虚拟主机可以改动,默认localhost。
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
本文链接:http://www.yunweipai.com/35147.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52742.html