首页 Tomcat教程tomcat-常见配置详解

tomcat实战案例: 应用部署实现基于WEB的管理

tomcat结合反向代理实现tomcat部署

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

常见配置详解
端口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

tomcat实战案例: 应用部署实现基于WEB的管理

tomcat结合反向代理实现tomcat部署

网友评论comments

发表评论

邮箱地址不会被公开。

暂无评论

Copyright © 2012-2021 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部