我已经在centos 7.2服务器上设置了tomcat9。“服务器状态”和“管理器应用程序”按钮正在工作。但当您单击“主机管理器”按钮时,它会显示403访问被拒绝。
我的tomcat-users.xml中包含以下内容:
<tomcat-users>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="my-admin" password="secret" roles="manager-gui,manager-status"/>
</tomcat-users>
这是我的管理器context.xml文件中的内容。在/usr/local/tomcat/webapps/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" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
-->
</Context>
我注释掉了只能从本端IP (127.0.0.1)访问tomcat的IP限制。
我还尝试暂时禁用SELinux,看看这是否是问题所在。但我还是得到了同样的结果。
为什么这不起作用?我怎么才能纠正它呢?
发布于 2020-06-05 22:05:15
更改tomcat/webapps/manager/META-INF/context.xml文件,如下所示:
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|66.66.66.666" />
其中66.66.66.666是您的远程IP地址。有关更多详细信息,请参阅文档- http://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Remote_Address_Valve
https://stackoverflow.com/questions/45126914
复制相似问题