如何设置Apache solr管理员密码

Sha*_*fiq 21 solr sunspot-solr

我对solr不太熟悉.我成功安装了solr.它使用的是码头网络服务器.我的solr版本是4.10.3.管理员页面不受密码保护.任何人都可以访问它.我想在solr admin上应用paaword.我该怎么办?

Sum*_*P4U 24

在使用solr 6.1和jetty运行的solr admin中启用身份验证

前提条件:

  1. Solr版本6.1

  2. Solr在系统中成功运行

  3. Solr Admin穿过码头

处理:

1.编辑jetty.xml

编辑文件"server/etc/jetty.xml"在Configure标记结束之前添加以下内容

<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>
Run Code Online (Sandbox Code Playgroud)

2.编辑webdefault.xml

编辑文件"server/etc/webdefault.xml"在web-app标记结束之前添加以下内容

<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>core1-role</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Test Realm</realm-name>
  </login-config>
Run Code Online (Sandbox Code Playgroud)

特别说明:

role-name标记中使用的值需要与"realm.properties"文件中使用的值相同

3.创建新文件"realm.properties"

在"server/etc /"位置创建名为"realm.properties"的文件,并将以下内容放入

admin: admin123,core1-role
Run Code Online (Sandbox Code Playgroud)

用户名: admin

密码: admin123

角色名称: core1-role

(这需要与服务器/ etc/webdefault.xml"文件中的role-name标记中使用的名称相同)

4.最后一步

重启Solr服务器

现在在浏览器中访问Solr http:// localhost:8983/solr / 您会发现浏览器要求usernamepassword.输入usernamepassword.

在此输入图像描述


Man*_*ojP 23

对于低于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> 
Run Code Online (Sandbox Code Playgroud)

对于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>
Run Code Online (Sandbox Code Playgroud)

更新/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>
Run Code Online (Sandbox Code Playgroud)

/example/etc/realm.properties :

admin: s3cr3t, admin-role
Run Code Online (Sandbox Code Playgroud)

用户名= admin 密码= 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
Run Code Online (Sandbox Code Playgroud)

有关更多信息,您可以帮助解决维基文档

  • 这是有效的,管理员现在是安全的,但REST端点(例如example.com:8983/solr/mycore/select?q=*%3A*&wt=json&indent=true)现在正在进行身份验证.我如何才能保护管理员Web界面,但是在没有身份验证的情况下保留REST端点? (9认同)

小智 6

如果你使用的是tomcat,

Open [Tomcat install dir]\tomcat-users.xml for editing.
Run Code Online (Sandbox Code Playgroud)

<tomcat-user>元素中添加以下行并保存更改(使用您自己的用户名和密码):

<role rolename="solr_admin"/><user username="your_username"  password="your_password"  roles="solr_admin"/>
Run Code Online (Sandbox Code Playgroud)

打开Tomcat安装dir\webapps\solr\WEB-INF\web.xml进行编辑.路径中的"solr"是您要保护的实例的名称.通常这是"solr",但如果您正在运行高级设置,则可能会有所不同.在<web-app>元素中添加以下行:

<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>
Run Code Online (Sandbox Code Playgroud)

保存更改并重新启动Tomcat.通过启动新的浏览器会话并导航到您的站点来测试您的更改,例如.http:// localhost:8080/solr /应该提示您输入凭据.

如果正在修改Tomcat安装目录tomcat-users.xml文件,请转到Project Explorer中Servers下的tomcat-users.xml文件,并在那里添加更改.