添加此功能主要是为了增加solr服务器的安全性,不能随便让人访问。

 

1.      tomcatF:\Tomcat 6.0.26_solr\conf\tomcat-users.xml添加用户角色并指定访问的用户名密码

 

[html] view plain copy

  1. <role rolename="solr"/>  

  2. <user username="admin" password="admin" roles="solr"/>  

 

 

 

2. F:\Tomcat6.0.26_solr\webapps\solr\WEB-INF\web.xm中添加用户访问权限设置

 

[html] view plain copy

  1. <security-constraint>  

  2.       <web-resource-collection>  

  3.           <web-resource-name>Solr Lockdown</web-resource-name>  

  4.           <url-pattern>/</url-pattern>  

  5.           <http-method>GET</http-method>  

  6.           <http-method>POST</http-method>  

  7.       </web-resource-collection>  

  8.       <auth-constraint>  

  9.           <description>This applies only to the "tomcat" security role</description>  

  10.           <role-name>solr</role-name>  

  11.           <role-name>admin</role-name>  

  12.       </auth-constraint>  

  13.       <user-data-constraint>  

  14.           <transport-guarantee>NONE</transport-guarantee>  

  15.       </user-data-constraint>  

  16.   </security-constraint>  

  17.     

  18.   <login-config>  

  19.       <auth-method>BASIC</auth-method>  

  20.       <realm-name>Solr</realm-name>  

  21.   </login-config>  



 

 

 

如果弹出此框并且能正常登录,说明已经配置成功