前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Tomcat 9访问 Host Manager

Tomcat 9访问 Host Manager

作者头像
拓荒者
发布2019-03-11 15:31:34
2K0
发布2019-03-11 15:31:34
举报
文章被收录于专栏:运维经验分享运维经验分享

第一步:下载tomcat。

由于机器环境是win7 旗舰版 64位,所以选择下载64-bit windows .zip。

Tomcat 9.0是绿色版,解压完成就可以使用。在tomcat主目录下的bin目录中,双击startup.bat文件就能够启动tomcat服务。然后在浏览器的地址栏中输入: localhost:8080,回车。成功访问tomcat。效果如下:

能够清楚的看到,有三个可以访问的链接。点击时需要用户名和密码。现在无法访问。

  • Server Status
  • Manager App
  • Host Manager

第二步:配置tomcat-users.xml 文件

在主目录的cong文件夹下找到tomcat-users.xml 文件中配置用户角色:

针对第三个按钮“Host Manager”,配置角色时一定把角色配全。修改tomcat-users.xml 文件,加入如下代码:

[html] view plain copy

  1. <role rolename="admin-gui"/>  
  2. <role rolename="manager-gui"/>    
  3. <user username="tomcat" password="s3cret" roles="admin-gui,manager-gui"/>  

配置tomcat-users.xml文件后,重新启动tomcat服务。在浏览器的地址栏中输入: localhost:8080,回车。成功访问tomcat,点击要访问的 “Host Manager”在弹出的“身份验证”框中输入用户名:tomcat,密码:s3cret,点击登录按钮。效果如下:

然后就可以顺利访问“Host  Manager”了。

以下内容可以忽略。

--------------------------------------------------------------------------------------------------

  • Server Status
  • Manager App
  • Host Manager
  • 前两个按钮和manager相关,具体角色名为
    • manager-gui - allows access to the HTML GUI and the status pages
    • manager-script - allows access to the text interface and the status pages
    • manager-jmx - allows access to the JMX proxy and the status pages
    • manager-status - allows access to the status pages only
  • 第三个按钮和admin相关,具体角色名为
    •     admin-gui - allows access to the HTML GUI and the status pages
    •     admin-script - allows access to the text interface and the status pages

所以在 tomcat-users.xml 如果不注重安全性,只是测试用的话,对应部分可以简单地写成下面这个样子:

---------------------------------

  <role rolename="admin"/>   <role rolename="manager-script"/>   <role rolename="manager-gui"/>   <role rolename="manager-jmx"/>   <role rolename="manager-status"/>   <role rolename="admin-gui"/>   <role rolename="admin-script"/>   <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

---------------------------------

很多网页没说到第三个按钮针对的角色。不添加admin-gui和admin-script的话,第三个按钮就会出现访问被拒绝的问题(access denied ....)。

详细说明可以参考 Tomcat 的文档(http://tomcat.apache.org/migration.html#Manager_application):

Manager application

The Manager application has been re-structured for Tomcat 7 onwards and some URLs have changed. All URLs used to access the Manager application should now start with one of the following options: <ContextPath>/html for the HTML GUI <ContextPath>/text for the text interface <ContextPath>/jmxproxy for the JMX proxy <ContextPath>/status for the status pages Note that the URL for the text interface has changed from "<ContextPath>" to "<ContextPath>/text". The roles required to use the Manager application were changed from the singlemanager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access. manager-gui - allows access to the HTML GUI and the status pages manager-script - allows access to the text interface and the status pages manager-jmx - allows access to the JMX proxy and the status pages manager-status - allows access to the status pages only The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection: users with the manager-gui role should not be granted either the manager-script ormanager-jmx roles. if the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session. The roles command has been removed from the Manager application since it did not work with the default configuration and most Realms do not support providing a list of roles.

  • <ContextPath>/html for the HTML GUI
  • <ContextPath>/text for the text interface
  • <ContextPath>/jmxproxy for the JMX proxy
  • <ContextPath>/status for the status pages

Note that the URL for the text interface has changed from "<ContextPath>" to "<ContextPath>/text". The roles required to use the Manager application were changed from the singlemanager role to the following four roles. You will need to assign the role(s) required for the functionality you wish to access.

  • manager-gui - allows access to the HTML GUI and the status pages
  • manager-script - allows access to the text interface and the status pages
  • manager-jmx - allows access to the JMX proxy and the status pages
  • manager-status - allows access to the status pages only

The HTML interface is protected against CSRF but the text and JMX interfaces are not. To maintain the CSRF protection:

  • users with the manager-gui role should not be granted either the manager-script ormanager-jmx roles.
  • if the text or jmx interfaces are accessed through a browser (e.g. for testing since these interfaces are intended for tools not humans) then the browser must be closed afterwards to terminate the session.

The roles command has been removed from the Manager application since it did not work with the default configuration and most Realms do not support providing a list of roles.

Host Manager application

The Host Manager application has been re-structured for Tomcat 7 onwards and some URLs have changed. All URLs used to access the Host Manager application should now start with one of the following options: <ContextPath>/html for the HTML GUI <ContextPath>/text for the text interface Note that the URL for the text interface has changed from "<ContextPath>" to "<ContextPath>/text". The roles required to use the Host Manager application were changed from the singleadmin role to the following two roles. You will need to assign the role(s) required for the functionality you wish to access. admin-gui - allows access to the HTML GUI and the status pages admin-script - allows access to the text interface and the status pages The HTML interface is protected against CSRF but the text interface is not. To maintain the CSRF protection: users with the admin-gui role should not be granted the admin-script role. if the text interface is accessed through a browser (e.g. for testing since this inteface is intended for tools not humans) then the browser must be closed afterwards to terminate the session.

  • <ContextPath>/html for the HTML GUI
  • <ContextPath>/text for the text interface

Note that the URL for the text interface has changed from "<ContextPath>" to "<ContextPath>/text". The roles required to use the Host Manager application were changed from the singleadmin role to the following two roles. You will need to assign the role(s) required for the functionality you wish to access.

  • admin-gui - allows access to the HTML GUI and the status pages
  • admin-script - allows access to the text interface and the status pages

The HTML interface is protected against CSRF but the text interface is not. To maintain the CSRF protection:

  • users with the admin-gui role should not be granted the admin-script role.
  • if the text interface is accessed through a browser (e.g. for testing since this inteface is intended for tools not humans) then the browser must be closed afterwards to terminate the session.

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018/04/10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
多因子身份认证
多因子身份认证(Multi-factor Authentication Service,MFAS)的目的是建立一个多层次的防御体系,通过结合两种或三种认证因子(基于记忆的/基于持有物的/基于生物特征的认证因子)验证访问者的身份,使系统或资源更加安全。攻击者即使破解单一因子(如口令、人脸),应用的安全依然可以得到保障。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档