Linux 403 Tomcat 拒绝访问

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

403 Access Denied in Tomcat

linuxtomcat

提问by John Doe

I have the following in the tomcat-users.xml:

我有以下内容tomcat-users.xml

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

If I go to http://localhost:8080/manager/html, I'm asked about username and password (as far as I understand, about these from the tomcat-users.xml), but when I enter them, I get:

如果我去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...

What could be a reason of such a behavior? Thanks in advance.

这种行为的原因是什么?提前致谢。

采纳答案by alain.janinm

To use the web administration gui you have to add the gui role.

要使用 Web 管理 gui,您必须添加gui role.

In [Tomcat installation path]/conf/tomcat-users.xmlyou can define roleand affect them to user. For example :

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


Note :

笔记 :

You may not have any default username and passworddefined here so it's always good to take the time to do this configuration or you'll encounter issue when using Tomcat integrated in IDE like NetBeans. Indeed it will require these credentials in order to use it properly.

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