Solr的主界面加登录权限

如题:效果如下图zu

只需两步:

1.tomcat-users.xml   下添加 

<user username="admin" password="new-password" roles="admin,manager"/>

2.solr服务下的web.xml

添加以下代码:

<security-constraint>
	<web-resource-collection>
		<web-resource-name>Restrict access to Solr admin</web-resource-name>
		<url-pattern>/admin/*</url-pattern>
		<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>
		<role-name>manager</role-name>
	</auth-constraint>
	<user-data-constraint>
		<transport-guarantee>NONE</transport-guarantee>
	</user-data-constraint>
</security-constraint>
<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>default</realm-name>
</login-config>
  

  重启即可。

原文地址:https://www.cnblogs.com/wudi521/p/5570577.html