[英]How to configure tomcat web.xml and tomcat-users.xml to secure a tomcat page
我想使用web.xml和tomcat-users.xml保护tomcat中的管理页面。它不起作用。
这是我的tomcat-users.xml的内容
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="webadmin"/>
<user username="kumar" password="kumar" roles="manager"/>
</tomcat-users>
和内容的WEB-INF / web.xml
<resource-env-ref>
<description>abc.com/</description>
<resource-env-ref-name>player</resource-env-ref-name>
<resource-env-ref-type>org.apache.catalina.UserDatabase</resource-env-ref-type>
</resource-env-ref>
<security-constraint>
<display-name>player</display-name>
<web-resource-collection>
<web-resource-name>personal</web-resource-name>
<!-- Define the context-relative URL(s) to be protected -->
<url-pattern>abc.com</url-pattern>
<!-- If you list http methods, only those methods are protected -->
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<!-- Anyone with one of the listed roles may access this area -->
<role-name>webadmin</role-name>
</auth-constraint>
</security-constraint>
<!-- Default login configuration uses form-based authentication -->
<login-config>
</form-login-config>-->
<auth-method>BASIC</auth-method>
<realm-name>player</realm-name>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
<role-name>webadmin</role-name>
</security-role>
请让我知道需要在这些xml中添加什么。
考虑到对tomcat管理器GUI的访问,在tomcat-users.xml中没有设置“管理器”的角色。
您必须指定这些角色之一。
您可以在Manager Web应用程序的web.xml文件中找到角色名称。 可用角色为:• manager-gui-访问HTML界面。 • manager-status-仅访问“服务器状态”页面。 • manager-script-访问本文档中描述的工具友好的纯文本界面以及“服务器状态”页面。 • manager-jmx-访问JMX代理界面和“服务器状态”页面。
请查看此链接以获取更多信息, http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html
希望对您有所帮助,谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.