Java 在 tomcat 7.0.42 上拒绝 403 访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19325636/
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-08-12 16:08:10  来源:igfitidea点击:

403 access denied on tomcat 7.0.42

javaapachetomcatnetbeans

提问by Umair

I am having error 403 access denied on tomcat 7.0.42while accessing Tomcat Manager App.

在访问 Tomcat Manager App时,我在 tomcat 7.0.42 上遇到错误403 访问被拒绝

This is what I have in tomcat-user.xmlfile. I have tried changing roles over and over but did not work.

这就是我在tomcat-user.xml文件中的内容。我曾多次尝试改变角色,但没有奏效。

Note: - I start/stop tomcat from NetBeans 7.3.1

注意: - 我从 NetBeans 7.3.1 启动/停止 tomcat

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
 <role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-script" />
</tomcat-users>

采纳答案by grepit

Remove the manager-script and add "manager-gui,manager-status".

删除 manager-script 并添加“manager-gui,manager-status”。

To access the HTML interface, you need to have the manager-gui role, but you must NOT have the manager-script or manager-jmx roles.

要访问 HTML 界面,您需要具有 manager-gui 角色,但不能具有 manager-script 或 manager-jmx 角色。

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

some information for you about roles from http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

一些关于角色的信息来自http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

  • manager-gui — Access to the HTML interface.
  • manager-status — Access to the "Server Status" page only.
  • manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
  • manager-jmx — Access to JMX proxy interface and to the "Server Status" page.
  • manager-gui — 访问 HTML 界面。
  • manager-status — 仅访问“服务器状态”页面。
  • manager-script — 访问本文档中描述的工具友好的纯文本界面,以及“服务器状态”页面。
  • manager-jmx — 访问 JMX 代理接口和“服务器状态”页面。

回答by bynu022

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

Add these to end of the tomcat-users.xml before tag located inside conf folder.

将这些添加到位于 conf 文件夹内的标记之前的 tomcat-users.xml 的末尾。

回答by Yin

I tied tomcat7 on ubuntu, and found that if you configure like this:

我在ubuntu上绑定了tomcat7,发现如果你这样配置:

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

admin1 will work OK, but admin2 will not have the access. It seems that the order of the roles matters.

admin1 可以正常工作,但 admin2 没有访问权限。似乎角色的顺序很重要。