8

对于生产来说,拥有一个甚至不询问登录凭据的 solr 管理员是不安全的。如何禁用默认提供的 solr 管理页面?我只是希望我的 webapp 使用 Solr 进行搜索词索引。

4

4 回答 4

10

我强烈建议保留管理页面以进行调试。它在许多情况下拯救了我。有一些方法可以将其限制为仅通过 HTTP 身份验证的用户:http ://wiki.apache.org/solr/SolrSecurity#Jetty_example 。您可能需要解压缩并重新压缩您的 web 应用程序。

但是,如果您仍想禁用整个管理部分,您可以注释掉 ${SOLR_HOME}/project/solr/conf/solrconfig.xml 中的管理 requestHandler。

于 2012-05-27T18:57:14.780 回答
2

只需向 Solr Web 应用程序添加安全约束,您就可以使用密码保护您的管理页面。

Solr 3.6 的代码段:

  <security-constraint>
    <!-- This protects your admin interface and grants access to role Solr-Admin -->
    <web-resource-collection>
    <web-resource-name>Solr admin</web-resource-name>
      <!--url-pattern>/admin/*</url-pattern-->
      <url-pattern>/evu/admin/*</url-pattern>
      <url-pattern>/webcrawl/admin/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>Solr-Admin</role-name>
    </auth-constraint>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>

  <security-constraint>
    <!-- This protects your admin interface and grants access to roles Solr-Admin and Solr-Updater -->
    <web-resource-collection>
      <web-resource-name>Solr Update</web-resource-name>
      <url-pattern>/update/*</url-pattern>
      <url-pattern>/evu/update/*</url-pattern>
      <url-pattern>/webcrawl/update/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>Solr-Admin</role-name>
      <role-name>Solr-Update</role-name>
    </auth-constraint>
    <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
  </security-constraint>

  <security-constraint>
    <!-- This one is necessary to show the image on the Solr start page -->
    <web-resource-collection>
      <web-resource-name>Solr Admin images</web-resource-name>
      <url-pattern>*.png</url-pattern>
    </web-resource-collection>
    <auth-contraint>
      <role-name>*</role-name>
    </auth-contraint>
  </security-constraint>

  <security-role>
    <description>The role that is required to administer Solr</description>
    <role-name>Solr-Admin</role-name>
  </security-role>
  <security-role>
    <description>The role that is required to update the Solr index</description>
    <role-name>Solr-Update</role-name>
  </security-role>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Solr</realm-name>
  </login-config>
</web-app>

在 Solr 4 中,您必须保护管理界面的以下资源:

/admin/*
/admin.html
于 2012-11-23T13:45:41.530 回答
0

sudo vim /opt/solr-4.8.1/example/etc/jetty.xml 更改

  <!-- This connector is currently being used for Solr because it
          showed better performance than nio.SelectChannelConnector
          for typical Solr requests.  -->
    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.bio.SocketConnector">
            <Set name="host">0.0.0.0</Set>
            <Set name="port"><SystemProperty name="jetty.port" default="8983"/></Set>
            <Set name="maxIdleTime">50000</Set>
            <Set name="lowResourceMaxIdleTime">1500</Set>
            <Set name="statsOn">false</Set>
          </New>
      </Arg>
    </Call>

 <!-- This connector is currently being used for Solr because it
          showed better performance than nio.SelectChannelConnector
          for typical Solr requests.  -->
    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.bio.SocketConnector">
            <Set name="host">127.0.0.1</Set>
            <Set name="port"><SystemProperty name="jetty.port" default="8983"/></Set>
            <Set name="maxIdleTime">50000</Set>
            <Set name="lowResourceMaxIdleTime">1500</Set>
            <Set name="statsOn">false</Set>
          </New>
      </Arg>
    </Call>

然后 sudo service solrd restart

于 2016-12-01T09:05:18.727 回答
-3

最简单的方法:

iptables -A INPUT -p tcp --dport 8983 -j DROP

iptables -A 输入 -p tcp -s 127.0.0.1 --dport 8983 -j 接受

有了这个命令!

于 2013-03-04T00:00:47.723 回答