[故障排查]Tomcat 8.5版本无权访问status页面

2018-12-05 0 条评论 274 次阅读 1 人点赞

1. 故障环境

# centos版本
[root@JavaDev-183 application]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
# jdk版本
[root@JavaDev-183 application]# java -version
openjdk version "1.7.0_191"
OpenJDK Runtime Environment (Zulu 7.24.0.1-linux64) (build 1.7.0_191-b08)
OpenJDK 64-Bit Server VM (Zulu 7.24.0.1-linux64) (build 24.191-b08, mixed mode)
# Tomcat版本
[root@JavaDev-183 application]# ll
total 9420
drwxr-xr-x 9 root root 220 Dec 6 21:52 apache-tomcat-8.5.35
-rw-r--r-- 1 root root 9642757 Dec 6 21:52 apache-tomcat-8.5.35.tar.gz
lrwxrwxrwx 1 root root 33 Dec 6 21:53 tomcat -> /application/apache-tomcat-8.5.35

2. 故障信息及排查

这肯定是没有权限,那么我们为它增加授权用户:

[root@JavaDev-183 conf]# tail -4 /application/tomcat/conf/tomcat-users.xml 
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>
</tomcat-users>
# 重启tomcat服务
[root@JavaDev-183 conf]# /application/tomcat/bin/shutdown.sh & /application/tomcat/bin/startup.sh 
[root@JavaDev-183 conf]# netstat -lntup|grep 8080
tcp6 0 0 :::8080 :::* LISTEN 1889/java 

再次检查,故障依旧:
【故障分析】在Tomcat 8.0版本,是不会有这样的错误的,目前是8.5版本,有可能是Tomcat做了更新;

3. 故障解决

找到manager项目的配置文件,对比两个版本之间的配置:

vim webapps/manager/META-INF/context.xml

把8.5版本增加的验证部分隐藏即可解决问题。

[root@JavaDev-183 conf]# tail -7 /application/tomcat/webapps/manager/META-INF/context.xml 
<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" />
-->
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
[root@JavaDev-183 conf]# /application/tomcat/bin/shutdown.sh & /application/tomcat/bin/startup.sh 
[1] 1961
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /root/.sdkman/candidates/java/current
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Using CATALINA_BASE: /application/tomcat
Using CATALINA_HOME: /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME: /root/.sdkman/candidates/java/current
Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@JavaDev-183 conf]# netstat -lntup|grep 8080
tcp6 0 0 :::8080 :::* LISTEN 1979/java 

掌柜

让未来超越过去!

文章评论(0)