403 Tomcat中拒绝访问

时间:2012-06-18 09:30:10

标签: linux tomcat

我在tomcat-users.xml中有以下内容:

<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<user username="aname" password="apassword" roles="admin,manager"/>
</tomcat-users>

如果我转到http://localhost:8080/manager/html,我会被问及用户名和密码(据我所知,这些来自tomcat-users.xml),但当我输入时,我得到:

403 Access Denied
You are not authorized to view this page.

If you have already configured the Manager application to allow access and you have used your browsers back button...

这种行为可能是什么原因?提前谢谢。

1 个答案:

答案 0 :(得分:23)

要使用网络管理gui,您必须添加gui role

[Tomcat installation path]/conf/tomcat-users.xml中,您可以定义role并将其影响到user。例如:

<tomcat-users>
    <role rolename="admin"/>
    <role rolename="admin-gui"/>
    <role rolename="manager"/>
    <role rolename="manager-gui"/>

    <user username="name" password="pwd" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>

注意:

您可能没有在此定义任何默认用户名和密码,因此花时间进行此配置总是好的,或者在使用NetBeans中集成的Tomcat时会遇到问题。实际上,它需要这些凭证才能正确使用它。