Tomcat在服务端Manager App无法打开

Manager App无法打开,主要有2个原因
  1. 没有设置登录账号。解决方法:进入到你自己的tomcat安装目录下,在conf找到tomcat-users.xml文件
    ,添加如下内容:

    <role rolename="tomcat"/>
    <role name="role1"/>
    
    <role rolename="manager-gui"/>  
    <role rolename="admin-gui"/>  
    <user username="test" password="123456" roles="manager-gui,admin-gui"/>

    那么,重启tomcat,可由test用户登录。

  2. 在操作完成上1步,还是不能操作。那可能是你的tomcat是部署在远程的服务器端。tomcat默认情况下只能在本地进入Manager App管理。远程管理可能会出现错误如下:

 You are not authorized to view this page.

By default the 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 Manager's context.xml file.

If you have already configured the 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 Manager application. You will need to reset this protection by returning to the main Manager page. Once you return to this page, you will be able to continue using the 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 manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.

那是不是没有办法解决了呢?参考overflow解决方法(传送门)。
解决办法就是修改,【tomcat目录】/webapps/manager/manager\META-INF\context.xml文件。
修改为:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<Context antiResourceLocking="false" privileged="true" >
  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
</Context>

发现区别没,其实就是对代码限制本地访问注解。

  <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

这段代码被注解了。

参考文献:

  1. 打开tomcat管理界面。http://blog.csdn.net/draling/article/details/42487305
  2. Manager App打开受限。http://stackoverflow.com/questions/36703856/access-tomcat-manager-app-from-different-host
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值