Can't access Tomcat 8 Manager App

余生长醉 提交于 2019-11-28 18:53:24
deepblue

AFAIK Tomcat blocks access to the Manager App (manager/html) for all hosts but localhost in its default configuration.

To be able to access the manager GUI with http://[hostname]:8080/manager/html, configure this in the configuration files server.xml and the context.xml of the manager application:

Step 1: In [tomcat-install-dir]/conf/server.xml edit the Connector element and add your IP as well as useIPVHosts="true", i.e.:

<Connector port="9009" protocol="AJP/1.3" redirectPort="9443" 
           address="192.168.0.9" useIPVHosts="true" />

address="0.0.0.0" is probably not what you want to insert here, as it exposes the manager GUI to all machines on the network.

Step 2: In [tomcat-install-dir]/webapps/manager/META-INF/context.xml, edit the Valve element and add your IP:

<Context antiResourceLocking="false" privileged="true">

    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="192\.168\.0\.9|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
</Context>

From tomcat 8 context documentation

privileged : Set to true to allow this context to use container servlets, like the manager servlet.

antiResourceLocking : If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur

Note, that I don't add another Valve element as you mentioned in the list of things you tried but instead I edit the existing one and just add my IP (192.168.0.9).

Step 3: Restart Tomcat and you should be able to access the manager GUI with localhost / 127.0.0.1 as well as with your hostname / IP.


Aside: Regarding your tomcat-users.xml, the Tomcat Manager HOW-TO states:

It is recommended to never grant the manager-script or manager-jmx roles to users that have the manager-gui role.

So you might want to introduce two users in your tomcat-users.xml, i.e.:

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

You should change:

docBase="${catalina.home}/webapps/manager"

to:

docBase="${catalina.base}/webapps/manager"

This is because you don't use Tomcat as distributed from upstream but the one which comes with Ubuntu.

Akash Rai

I think this might help for all of you because its work for me.

Here I'm using Apache tomcat 8:

root@akash-LIFEBOOK-A555:/opt/apache-tomcat-8.5.20/bin# ./version.sh 
Using CATALINA_BASE:   /opt/apache-tomcat-8.5.20
Using CATALINA_HOME:   /opt/apache-tomcat-8.5.20
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.5.20/temp
Using JRE_HOME:        /DATA/jre1.8.0_131/
Using CLASSPATH:       /opt/apache-tomcat-8.5.20/bin/bootstrap.jar:/opt/apache-tomcat-8.5.20/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.20
Server built:   Aug 2 2017 21:35:49 UTC
Server number:  8.5.20.0
OS Name:        Linux
OS Version:     4.4.0-98-generic
Architecture:   amd64
JVM Version:    1.8.0_131-b11
JVM Vendor:     Oracle Corporation

Edit tomcat-user.xml and added the roles and users

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

I also fetched same issue and what i did first added role user and passowrd in config/tomcat-users.xml then allowed my public ip in webapps/manager/META-INF/context.xml there initially local ip 127 added for use manager from same machine. there add your ip

Thiru Maran

You can simply do like if you want to access manager app on all machines. Go to {Tomcat_install_DIR}/webapps/manager/META-INF/ and edit context.xml put

<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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!