首页 > 数据库技术 > 详细

Securing Solr on Tomcat access using a user account

时间:2014-01-20 22:39:15      阅读:515      评论:0      收藏:0      [点我收藏+]
  • Open [Tomcat install dir]\tomcat-users.xml for editing.

  • Add the following lines within the <tomcat-user> element and save the changes (using your own username and password):

    <role rolename="solr_admin"/>
    
    <user username="your_username"
          password="your_password"
          roles="solr_admin"
          /> 

    Open [Tomcat install dir]\webapps\solr\WEB-INF\web.xml for editing.

    "solr" in the path is the name of the instance you want to secure. Typically this is "solr," but may be different if you are running an advanced setup. 

  • Add the following lines within the <web-app> element:

      <security-constraint>
        <web-resource-collection>
          <web-resource-name>Solr Lockdown</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>
      </security-constraint>
      <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Solr</realm-name>
      </login-config> 
  • Save the changes and restart Tomcat. Test your changes by starting a new browser session and navigating to your site, for ex. http://localhost:8080/solr/. You should be prompted for credentials.

  • Download the following communityserver_override.config file.

  • Place this file in the root of your Web site directory.

  • Find the section in this file which is highlighted below and change it to read
    http://your_username:your_password@localhost:8080/solr
    replacing "your_username" and "your_password" and the host URI with the configured values

    ?
    1
    2
    3
    4
    5
    <Override xpath="/CommunityServer/Search/Solr"  
              mode="change"
              name="host"
              value="<span style="background-color:#ffff00;">http://localhost:8080/solr</span>"
              />
  • Save changes.



    本人的操作:

    1.tomcat的conf/tomcat-users.xml  添加

    <role rolename="solr_admin"/>
    
    <user username="your_username"
          password="your_password"
          roles="solr_admin"
          /> 

    2.在bubuko.com,布布扣


    解压solr.war 找到web.xml

    添加如下代码在<web-app></web-app> 元素中

     <security-constraint>
        <web-resource-collection>
          <web-resource-name>Solr select Lockdown</web-resource-name>
          <url-pattern>/cs/select/*</url-pattern>
        </web-resource-collection>
      </security-constraint>


      <security-constraint>
        <web-resource-collection>
          <web-resource-name>Solr Lockdown</web-resource-name>
          <url-pattern>/</url-pattern> 
        </web-resource-collection>
        <auth-constraint>
          <role-name>solr_admin</role-name>
        </auth-constraint>
     
      </security-constraint>
      <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Solr</realm-name>
      </login-config> 





  • Securing Solr on Tomcat access using a user account

    原文:http://blog.csdn.net/baicp3/article/details/18506055

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
    © 2014 bubuko.com 版权所有
    打开技术之扣,分享程序人生!