版本:Tomcat 9.0.6

问题:访问HostManager页面出现 Access Denied 错误

403 Access Denied
You are not authorized to view this page.By default the Host Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Host Manager's context.xml file.If you have already configured the Host Manager application to allow access and you have used your browsers back button, used a saved book-mark or similar then you may have triggered the cross-site request forgery (CSRF) protection that has been enabled for the HTML interface of the Host Manager application. You will need to reset this protection by returning to the main Host Manager page. Once you return to this page, you will be able to continue using the Host Manager application's HTML interface normally. If you continue to see this access denied message, check that you have the necessary permissions to access this application.If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.For example, to add the admin-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.<role rolename="admin-gui"/>
<user username="tomcat" password="s3cret" roles="admin-gui"/>
Note that for Tomcat 7 onwards, the roles required to use the host manager application were changed from the single admin 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
admin-script - allows access to the text interface
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 interface is intended for tools not humans) then the browser must be closed afterwards to terminate the session.

通过查看英文的报错:If you wish to modify this restriction, you'll need to edit the Host Manager's context.xml file.

打开webapps,打开\tomcat\apache-tomcat-9.0.6\webapps\host-manager\META-INF\context.xml

参考:https://www.cnblogs.com/luoruiyuan/p/6518508.html的博客,做了以下的修改。

1 <Context antiResourceLocking="false" privileged="true" >
2   <Valve className="org.apache.catalina.valves.RemoteAddrValve"
3          allow="^.*$" />
4   <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
5 </Context>

将127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1这里的正则表达式修改为所有人都可以访问后,重启Tomcat再在另外一个浏览器IE打开还是出现403错误,并没有解决问题,于是只得再次阅读英文的报错,以及提示信息:

If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp. For example, to add the admin-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.
<role rolename="admin-gui"/>
<user username="tomcat" password="s3cret" roles="admin-gui"/>

所以在路径\tomcat\apache-tomcat-9.0.6\conf\tomcat-users.xml 下增加一个admin-gui role

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

重启Tomcat,再次刷新页面,完美解决问题:)

小结:

这次换用Tomcat 9 出现问题并没有照搬网上的解决方法,而是根据报错的情况,参考英文文档去解决问题,所以遇到问题首先想到的应该是根据报错的情况,尝试着先单独的去解决问题,而不是照本宣科的生搬硬套网上的解决办法,这个很重要?。ps:(英文水平真的有待提高/?)

2018-04-12     01:23:30

转载于:https://www.cnblogs.com/yitian09/p/8801600.html

Tomcat 9.0.6 HostManager页面 403 Access Denied 错误相关推荐

  1. 访问tomcat manager应用遇到的403 access denied错误

    我访问http://localhost:9032/manager/html时遇到403 access denied的页面,页面里提示的很清楚,在tomcat 9.0后,manager角色被拆分成了4个 ...

  2. Tomcat【环境搭建 02】Web端403 Access Denied You are not authorized to view this page解决方法(Tomcat 10.2.12 版本)

    1. 问题说明 启动Tomcat之后,我们常常是要打开Web端进行验证,其实Web端的功还有很多,但是有一些管理页面权限不足: 我们点击 Manager Status 或 Manager App 链接 ...

  3. MySQL Access denied错误的缘故情由

    作者:天极软件 起原:天极软件 当你试着联接MySQL效劳器时,如果你遇到Access denied错误,显示在下面的表指出一些你能用来纠正这个成绩的举措: 你是在安装MySQL当前运转mysql_i ...

  4. nginx php access denied,LNMP 解决Access Denied错误详细介绍

    处理搭建好LNMP环境之后,呈现了Access Denied错误 搭建好LNMP环境之后,呈现了Access Denied错误,现已扫除掉文件权限的问题也扫除掉是Nginx的问题,而是无法解析PHP的 ...

  5. Access denied错误的原因

    当你试着联接MySQL服务器时,如果你碰到Access denied错误,显示在下面的表指出一些你能用来更正这个问题的动作: 你是在安装MySQL以后运行mysql_install_db的脚本,来设置 ...

  6. java.security.AccessControlException: access denied 错误的解决方法

    留言板系统,运行时提示java.security.AccessControlException: access denied 错误,这种情况是不允许程序向客户端读写文件 所以我们必须人为让客户端授权允 ...

  7. tomcat8 进入不了Manager App 界面 403 Access Denied

    准备 1.注释掉context.xml中的value属性 使用下面的命令: vim /usr/local/tomcats/tomcat-daily/webapps/manager/META-INF/c ...

  8. mysql显示错误Access_关于mysql的access denied 错误解决方案

    mysql -u root -p 按回车,输入密码后提示access denied......ues password YES/NO的错误? 第一步: 这时你需要进入/etc/mysql目录下,然后s ...

  9. MTPuTTY连接Ubuntu\Linux SSH登陆出现Access Denied错误

    目录 一.异常错误 二.原因 三.解决方法 1.进入root用户 2.进入/etc/ssh/目录 3.添加PermitRootLogin yes 4.重启SSH 5.SSH重新连接Ubuntu 一.异 ...

最新文章

  1. 认识登录控件(Login、CreateUserWizard、LoginStatus和LoginName)
  2. 在Postgres中为插入语句生成UUID?
  3. Xcode终端常用的指令-终端输入
  4. java写入文件编码格式为ansi_Java读取、写入文件如何解决乱码问题
  5. 管道、通道、管程的区别
  6. 联想微型计算机M3500q怎么拆,联想ThinkCentre 超级Q 23 创新插拔 一机多用
  7. 如何查看2012服务器登录日志文件,怎样查看2012服务器远程过记录
  8. Security中常见的权限控制方式
  9. linq判断集合中相同元素个数_java----Collection集合常用方法
  10. redis(版本redis-5.0.2)的安装步骤
  11. tq2440修改默认串口不支持打印控制台
  12. 设计模式 ( 十二 ) 静态代理模式
  13. android拼音书写格式,Android自定义带拼音音调Textview
  14. 标签打印软件如何制作菱形标签
  15. 拼多多如何拉到足够的人去砍价,砍成一台iPhone12需要多少人?
  16. 如何搭建用户生命周期模型?
  17. oracle10g利用归档恢复,Oracle10g数据库归档与非归档模式下的备份与恢复
  18. 华为企业BG总裁阎力大:数字化转型激活指数级增长
  19. 实战Perl脚本测试
  20. 阿德莱德大学计算机专业教学,澳洲阿德莱德大学计算机硕士课程的专业设置如何?...

热门文章

  1. 深入理解HTML表格
  2. listview移动时 item背景颜色错位问题
  3. 常用的正则表达式验证类
  4. trouble identification check tree
  5. only SOY MILK IS NOT ENOUGH FOR BREAKFAST
  6. ismm rejection from cambridge
  7. statistics DATA in CHINA
  8. C#抽象类与接口的区别【转】
  9. 阅读作业:大泥球、敏捷、人件
  10. ThinkPHP5下自己写日志