Skip to main content
 首页 » 编程设计

solr之如何设置Apache Solr管理员密码

2025年02月15日22bjzhanghao

我对solr不太熟悉。我已经成功安装了solr。它正在使用 jetty 网络服务器。我的Solr版本是4.10.3。它的管理页面不受密码保护。任何人都可以访问它。我想在solr admin上应用paaword。我将如何做?

请您参考如下方法:

对于低于5的版本

如果您使用的是solr-webapp,则需要修改web.xml文件并添加以下行:

<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>  

对于Jetty服务器,您需要在/example/etc/webdefault.xml中添加以下行
<security-constraint> 
    <web-resource-collection> 
      <web-resource-name>Solr authenticated application</web-resource-name> 
      <url-pattern>/</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
      <role-name>**admin-role**</role-name> 
    </auth-constraint> 
  </security-constraint> 
 
  <login-config> 
    <auth-method>BASIC</auth-method> 
    <realm-name>Test Realm</realm-name> 
  </login-config> 

更新/example/etc/jetty.xml文件
<Call name="addBean"> 
      <Arg> 
        <New class="org.eclipse.jetty.security.HashLoginService"> 
          <Set name="name">Test Realm</Set> 
          <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set> 
          <Set name="refreshInterval">0</Set> 
        </New> 
      </Arg> 
    </Call> 
/example/etc/realm.properties:
admin: s3cr3t, admin-role 

用户名=管理员
密码= s3cr3t。
角色名称= admin-role

Solr版本5+

在最新的Solr版本中,文件夹结构已更改。您将在以下文件夹路径中找到所有文件。

{SOLR_HOME} /server/etc/jetty.xml
{SOLR_HOME} /server/etc/webdefault.xml

{SOLR_HOME}/server/etc/realm.properties处创建新的凭证文件:
admin: s3cr3t, admin-role 

有关更多信息,您可以帮助solr wiki docs