zoukankan      html  css  js  c++  java
  • Solr专题(四)Solr安全设置

     因为solr的admin界面默认只需要知道ip和端口就能直接访问,如果被别有用心的人盯上就很容易给你的系统带来重大的破坏,所以我们应该限制访问。

    请注意本例使用的是Solr7。

    Solr集成了以下几种验证方式:

    1. Basic自定义身份验证方式
    2. Kerberos身份验证方式
    3. Hadoop身份验证方式

     最简单的一种大概就是限制solr服务的访问ip,如果使用tomcat当做容器,可以在server.xml中配置可访问的ip:

    <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1,192.168.208.119"/>
    

    使用Basic认证

    添加用户配置文件realm.properties:

    admin:admin123,solr_admin  
    

    在/server/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>solr_admin</role-name>  
          <role-name>admin</role-name>  
        </auth-constraint>  
       
        <login-config>  
          <auth-method>BASIC</auth-method>  
          <realm-name>Solr Admin</realm-name>  
        </login-config>  
    </security-constraint> 
    

    在/server/contexts/solr-jetty-context.xml中的Configure属性中添加:

    <Get name="securityHandler">    
             <Set name="loginService">    
                     <New class="org.eclipse.jetty.security.HashLoginService">    
                             <Set name="name">admin</Set>
                            <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>    
                     </New>    
             </Set>    
    </Get> 
    

    重启solr,访问admin界面,提示需要输入密码才能访问。

  • 相关阅读:
    [转载]instanceof和typeof区别
    【转载】DNN架构
    Delphi实现高性能的Socket通讯服务器(完成端口模型IOCP)
    record, packed record和变体记录
    Delphi操作Word的几个知识点
    WinSock学习笔记6:IOCP完成端口模型
    MyEclipse 常用设置和操作方法
    PAIP.一些流氓软件的流氓营销方法.txt
    qq安全使用指南.txt
    海量数据高性能分页
  • 原文地址:https://www.cnblogs.com/yl-space/p/13329374.html
Copyright © 2011-2022 走看看