403 Access Denied on Tomcat 8 Manager App without prompting for user/password

前端 未结 16 2137
天涯浪人
天涯浪人 2020-12-01 01:39

I have set up tomcat 8 according to this, and I have the following tomcat-users.xml file:




        
相关标签:
16条回答
  • 2020-12-01 02:17

    I have to modify the following files

    $CATALINA_BASE/conf/Catalina/localhost/manager.xml and add following line

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

    This will allow tomcat to be accessed from any machine, if you want to grant access to specific IP then use the below value instead of allow="^.*$"

        <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192\.168\.11\.234" />
    
    0 讨论(0)
  • 2020-12-01 02:17

    I had to add both manager-gui and manager-script roles for it to work, in version 9.

    After getting the access to MangerApp, while trying to upload .war file, I got the exception

    org.apache.tomcat.util.http.fileupload.FileUploadBase$IOFileUploadException
    

    which I was able to solve using the answer of this post

    To get access for Host Manager, check this post

    0 讨论(0)
  • 2020-12-01 02:22

    If non of above works for you, make sure tomcat has access to manager folder under webapps (chown ...). The message is the exact same message, and It took me 2 hours to figure out the problem. :-)

    just for someone else who came here for the same issue as me.

    0 讨论(0)
  • 2020-12-01 02:23

    The solution that worked for me is edit context.xml files in both $CATALINA_HOME/webapps/manager/META-INF and $CATALINA_HOME/webapps/host-manager/META-INF where my ip is 123.123.123.123.

    <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|123.123.123.123" />
    </Context>
    

    I installed Tomcat 8.5 on Ubuntu and edited $CATALINA_HOME/conf/tomcat-users.xml:

    <role rolename="admin-gui"/>
    <role rolename="manager-gui"/>
    <user username="myuser" password="mypass" roles="admin-gui,manager-gui"/>
    

    However, I still couldn't access both Tomcat Web Application Manager (localhost:8080/manager/html) and Tomcat Virtual Host Manager (localhost:8080/host-manager/html) until I edited context.xml files.

    0 讨论(0)
  • 2020-12-01 02:23

    copy the below content to file tomcat-users.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.
    -->
    <tomcat-users xmlns="http://tomcat.apache.org/xml"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
                  version="1.0">
    <!--
      NOTE:  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 - the username and password are arbitrary. It is
      strongly recommended that you do NOT use one of the users in the commented out
      section below since they are intended for use with the examples web
      application.
    -->
    <!--
      NOTE:  The sample user and role entries below are intended for use with the
      examples web application. They are wrapped in a comment and thus are ignored
      when reading this file. If you wish to configure these users for use with the
      examples web application, do not forget to remove the <!.. ..> that surrounds
      them. You will also need to set the passwords to something appropriate.
    -->
    <!--
      <role rolename="tomcat"/>
      <role rolename="role1"/>
      <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
      <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
      <user username="role1" password="<must-be-changed>" roles="role1"/>
    -->
    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    
    <user username="notadmin" password="not_real_pass" roles="manager-gui"/>
    <user username="cargo" password="not_real_pass" roles="manager-script"/>
    
    
    </tomcat-users>
    

    I have tested, it just works!

    0 讨论(0)
  • 2020-12-01 02:24
    <role rolename="tomcat"/>
      <role rolename="manager-gui"/>
      <role rolename="admin-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <user username="admin" password="admin" roles="tomcat,manager-gui,admin-gui,manager-script,manager-jmx"/>
    
    
    Close all the session, once closed, ensure open the URL in incognito mode login again and it should start working
    
    0 讨论(0)
提交回复
热议问题