tomcat 笔记

1. tomcat 笔记

1.1. Tomcat Manager 中的角色分类

  • manager-gui 角色

允许访问 HTML GUI 和状态页面(即 URL 路径为 /manager/html/*)

  • manager-script 角色 (Maven 项目远程热部署)

允许访问文本界面和状态页面(即 URL 路径为 /manager/text/*)

  • manager-jmx 角色

允许访问 JMX 代理和状态页面(即 URL 路径为 /manager/jmxproxy/*)

  • manager-status 角色

仅允许访问状态页面(即 URL 路径为 /manager/status/*)

1.2. How to Allow Remote Access to Tomcat Manager

  1. The upstream-provided (example) webapps are not enabled by default, per upstream’s security recommendations, but are still available under the webapps.dist folder within the image to make them easier to re-enable.
  2. The configuration files are available in /usr/local/tomcat/conf/. By default, no user is included in the “manager-gui” role required to operate the “/manager/html” web application. If you wish to use this app, you must define such a user in tomcat-users.xml.

1.2.1. Configure Tomcat User Roles and Permissions

First, you need to create a user with the appropriate roles and permissions to access Tomcat Manager remotely. Edit the “tomcat-users.xml” file, which is typically located in the “conf” directory of your Tomcat installation. Add the following XML snippet inside the element:

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

Replace “your-username” and “your-password” with your desired credentials. Save the changes and restart Tomcat for the changes to take effect.

1.2.2. Modify the Tomcat Manager Remote Access Policy

Tomcat have a context file for each deployed web application under the conf/Catalina/localhost directory. It has the file with the same name as the web app like manager.xml or host-manager.xml.

So, if the file is not present, you need to create a file conf/Catalina/localhost/manager.xml and specify the rule to allow remote hosts.

sudo nano ${CATLINA_HOME}/conf/Catalina/localhost/manager.xml
Add the following content.

<Context privileged="true" antiResourceLocking="false" 
         docBase="{catalina.home}/webapps/manager">
    <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>

Save file and close it.

You also need to create an XML file for the host-manager web app to allow access for remote hosts.

sudo nano ${CATLINA_HOME}conf/Catalina/localhost/host-manager.xml   

Add the following content.

<Context privileged="true" antiResourceLocking="false" 
         docBase="{catalina.home}/webapps/host-manager">
    <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>

Save file and close it.

1.2.3. Access Tomcat Manager Remotely

http://your-tomcat-server-ip:port/manager/html
http://your-tomcat-server-ip:port/manager/status
http://your-tomcat-server-ip:port/manager/jmxproxy

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云满笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值