2018-11-09 Solr5.5.5服务器配置账号登录
[TOC]
Solr服务部署之后,无论是谁,都能直接访问,为保证Solr服务器的安全,不让被人随意登录,配置访问solr服务器要求输入账号和密码
1. tomcat配置,编辑conf/tomcat-users.xml,添加:
设置账号:admin;密码admin;
<role rolename="solr"/>
<user username="admin" password="admin" roles="solr"/>
2. solr服务配置,编辑webapps/solr/WEB-INFO/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>
3. 重启tomcat,访问:
http://localhost:8080/solr/admin.html
输入账号admin,密码admin,即可正常访问solr服务器