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界面,提示需要输入密码才能访问。

  • 相关阅读:
    如何用 Gerrit 提交代码到服务器
    营收奇迹:三消游戏Candy Crush Saga成功启示录
    flash进阶之路
    Flash笔记之swf居中和swf获取页面参数游戏全屏显示
    如何做一款成功的APP应用
    演义群侠扫盲
    笔记二 air android处理用户交互
    可以准备很多字体,玩家选择性下载
    AIR中调用exe或者bat可执行文件
    很好用的工具类
  • 原文地址:https://www.cnblogs.com/yl-space/p/13329374.html
Copyright © 2011-2022 走看看