java Tomcat 8.5 - 403 访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40503771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:17:09  来源:igfitidea点击:

Tomcat 8.5 - 403 Access Denied

javatomcatubuntu-16.04

提问by IlGala

I've created a virtual machine with Ubuntu 16.04 LTS and, following this guide, I've installed Tomcat 8.5and configured as follows:

我已经使用 Ubuntu 16.04 LTS 创建了一个虚拟机,并且按照本指南,我已经安装了Tomcat 8.5并配置如下:

/opt/tomcat/webapps/host-manager/META-INF/context.xml:

/opt/tomcat/webapps/host-manager/META-INF/context.xml

<Context antiResourceLocking="false" privileged="true">
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="192\.168\.1\.124|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />    
</Context>
<!-- my local ip is 192.168.1.124 so I've added it -->

/opt/tomcat/conf/tomcat-users.xml

/opt/tomcat/conf/tomcat-users.xml

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

No other configuration files has been modified.

没有修改其他配置文件。

The problem comes out when I try to access to the manager interface from my browser, it doesn't ask me any kind of credentials and throws me a 403 (Access Denied) error.

当我尝试从浏览器访问管理器界面时,问题就出现了,它不会询问我任何类型的凭据,而是向我抛出 403(拒绝访问)错误。

How can I fix this problem?

我该如何解决这个问题?

回答by Maheshwar Ligade

This is worked for me. Please check Find the CATALINA_HOME/webapps/manager/META-INF/context.xmlfile and add the comment markers around the Valve.

这对我有用。请检查查找CATALINA_HOME/webapps/manager/META-INF/context.xml文件并在 Valve 周围添加注释标记。

<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>

Tomcat8 Documentation.

Tomcat8 文档。