solr管理界面的用户验证(BASIC)

作用:保证Solr服务器的安全性,不让别人随意登陆Solr管理界面。管理界面如下图所示


修改apache-tomcat-8.0.47\conf文件夹下的tomcat-users.xml文件。添加用户角色并指定用户名和密码

<role rolename="solr"/>  
<user username="admin" password="admin" roles="solr"/>

修改apache-tomcat-8.0.47\webapps\solr\WEB-INF文件夹下的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>solr</role-name>
	<role-name>admin</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>


重新启动服务器,然后访问Solr管理界面


输入用户名密码,进行访问。保证了服务器的安全性。

猜你喜欢

转载自blog.csdn.net/u013517229/article/details/79447065
今日推荐