添加此功能主要是爲了增長solr服務器的安全性,不能隨便讓人訪問。html
1. 在tomcat的F:\Tomcat 6.0.26_solr\conf\tomcat-users.xml添加用戶角色並指定訪問的用戶名密碼web
[html] view plain copytomcat
<role rolename="solr"/> 安全
<user username="admin" password="admin" roles="solr"/> 服務器
2. 在F:\Tomcat6.0.26_solr\webapps\solr\WEB-INF\web.xm中添加用戶訪問權限設置app
[html] view plain copywebapp
<security-constraint> ide
<web-resource-collection> url
<web-resource-name>Solr Lockdown</web-resource-name> spa
<url-pattern>/</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>This applies only to the "tomcat" security role</description>
<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>Solr</realm-name>
</login-config>
若是彈出此框而且能正常登陸,說明已經配置成功