tomcat管理端的应用场景:

1.搭建与测试的时候开启管理端进行测试

2.生产环境中需要关闭管理端

配置开启管理端

1.配置远程访问

默认情况下manager和host-manager应用都是分别在webapps/manager/META-INF/context.xml和webapps/host-manager/META-INF/context.xml文件中限制只能本地访问对应应用:

null

allow这一行默认配置的是允许本地访问,可以直接注释掉红框中的内容或者修改allow的参数值为允许远程访问的ip,多个ip以|分隔,如allow="192.168.1.|192.168.2.2"表示允许192.168.1.下所有网段及192.168.2.2的ip访问;

我们这里配置为所有地址可访问:

[root@iZ2zegf84anoz74xvdnv8cZ tomcat]# vim webapps/manager/META-INF/context.xml
         allow="\d+.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1" />

[root@iZ2zegf84anoz74xvdnv8cZ tomcat]# vim webapps/host-manager/META-INF/context.xml
          allow="\d+.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1" />

d+表示任何
\表示转义字符

2.配置访问manager或host-manager的角色、用户密码

打开tomcat/conf/tomcat-users.xml文件,在...标签中添加访问角色及用户名、密码

<role rolename="manager-gui"/>
<user username="tomcat" password="123" roles="manager-gui"/>

rolename:

1.manager-gui:允许访问html接口(url路径为/manager/html/*)

2.manager-script:允许访问纯文本接口(url路径为/manager/text/*)

3.manager-jmx: 允许访问JMX代理接口(url路径为/manager/jmxproxy/*)

4.manager-status:允许访问Tomcat只读状态页面(url路径为/manager/status/*)

5.admin-gui:允许访问host manager页面(url路径为/host-manager/html*)

6.admin-script:允许访问host manager的脚本页面

roles可配置多个,以,分隔,如:

<user username="tomcat" password="123" roles="manager-gui,admin-gui"/>

配置完成后,重启tomcat,重新访问对应界面,输入用户名密码即可!!

配置关闭管理端

关闭管理端有两种方式:

1.在webapps/manager/META-INF/context.xml和webapps/host-manager/META-INF/context.xml文件中的allow配置为只允许127访问。

[root@iZ2zegf84anoz74xvdnv8cZ tomcat]# vim webapps/manager/META-INF/context.xml
         allow="\127.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1" />

[root@iZ2zegf84anoz74xvdnv8cZ tomcat]# vim webapps/host-manager/META-INF/context.xml
          allow="\127.\d+.\d+.\d+|::1|0:0:0:0:0:0:0:1" />

d+表示任何
\表示转义字符

2.把webapps/manager和webapps/host-manager目录删除或移动到其他位置,就不能访问管理端了,将会显示404。

results matching ""

    No results matching ""