solr -- 配置用户名和密码
2017-11-29 11:44
218 查看
Solr在5.0版本后,不再提供war包部署的方式:
1:
在D:\apache-solr-4.0.0\apache-solr-4.0.0\example\etc目录下新建role.properties文件,名字可随便。
#
# 这个文件定义用户名,密码和角色
#
# 格式如下
# <username>: <password>[,<rolename> ...]
#
#userName: password,role
test: 123,admin
2:编辑D:\apache-solr-4.0.0\apache-solr-4.0.0\example\contexts\solr.xml文件如下,文件中插入安全处理程序设置标签
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/solr</Set>
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
<Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
<!-- 安全处理程序设置 -->
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">TestRealm</Set> <!-- 一个名字-->
<!-- 引入刚刚新建的文件 -->
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
</New>
</Set>
</Get>
</Configure>
3:编辑D:\apache-solr-4.0.0\apache-solr-4.0.0\example\solr-webapp\webapp\WEB-INF\web.xml文件,插入
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr</web-resource-name> <!--描述-->
<url-pattern>/</url-pattern> <!-- 验证的网页的位置-->
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name> <!-- 验证的角色,别写成用户名,如有多个角色可以写多个role-name 标签-->
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method> <!-- 关键-->
<realm-name>TestRealm</realm-name>
</login-config>
4:重启服务就可以了。
相关链接:https://www.cnblogs.com/hihtml5/p/5775896.html
http://www.mossle.com/docs/auth/html/ch109-preauth.html
1:
在D:\apache-solr-4.0.0\apache-solr-4.0.0\example\etc目录下新建role.properties文件,名字可随便。
#
# 这个文件定义用户名,密码和角色
#
# 格式如下
# <username>: <password>[,<rolename> ...]
#
#userName: password,role
test: 123,admin
2:编辑D:\apache-solr-4.0.0\apache-solr-4.0.0\example\contexts\solr.xml文件如下,文件中插入安全处理程序设置标签
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/solr</Set>
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/solr.war</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home"/>/etc/webdefault.xml</Set>
<Set name="tempDirectory"><Property name="jetty.home" default="."/>/solr-webapp</Set>
<!-- 安全处理程序设置 -->
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">TestRealm</Set> <!-- 一个名字-->
<!-- 引入刚刚新建的文件 -->
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
</New>
</Set>
</Get>
</Configure>
3:编辑D:\apache-solr-4.0.0\apache-solr-4.0.0\example\solr-webapp\webapp\WEB-INF\web.xml文件,插入
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr</web-resource-name> <!--描述-->
<url-pattern>/</url-pattern> <!-- 验证的网页的位置-->
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name> <!-- 验证的角色,别写成用户名,如有多个角色可以写多个role-name 标签-->
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method> <!-- 关键-->
<realm-name>TestRealm</realm-name>
</login-config>
4:重启服务就可以了。
相关链接:https://www.cnblogs.com/hihtml5/p/5775896.html
http://www.mossle.com/docs/auth/html/ch109-preauth.html
相关文章推荐
- solr基于jetty容器配置后台登陆角色用户名密码
- Tomcat Manager 用户名和密码配置
- 如何配置netbeans中绑定的tomcat管理员用户名和密码
- 用Samba创建配置共享文件夹 (无用户名密码验证)
- 如何配置netbeans中绑定的tomcat管理员用户名和密码
- 【个人笔记重点,不作为参考】主题:ubuntu下的Samba配置:使每个用户可以用自己的用户名和密码登录自己的home目录
- MongoDb3配置远程连接-(带授权)即必须用户名密码来远程登录(win10)
- 如何配置netbeans中绑定的tomcat管理员用户名和密码
- tomcat7.0用户名和密码配置
- 匿名无须交互输入用户名和密码的samba配置方法(security = user)
- netbeans中tomcat的用户名与密码配置(简易)
- tomcat7.0用户名和密码配置
- WampServer PHP服务配置方法(允许外部访问、phpmyadmin设置为输入用户名密码才可登录等)
- 在spring中配置mongodb的用户名和密码
- Tomcat 配置Manager用户名与密码
- 解决整合spring和mybatis后数据源配置文件读取错误,错误提示数据库用户名密码错误。
- Tomcat Manager用户名和密码配置
- 在Netbeans下配置Tomcat manager用户名与密码
- tomcat 下配置manager的用户名和密码的方式