0

我在 Glassfish 中部署了一个Apache Solr实例,我通过Solrj使用 Java 代码中的这个 Solr 实例。问题是,我想限制对 Solr 的访问,以便只有这个 Java 代码可以访问它(代码可以从不同的 IP 地址运行)。

我的第一个想法是更改已web.xml部署的 Solr 实例,以使用 Glassfish 的基于文件的领域添加基本身份验证,因为我使用它来限制对另一个项目中 REST 接口的访问。所以我在 Solr web.xml 中添加了以下几行:

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Secure</web-resource-name>
      <url-pattern>/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
      <http-method>HEAD</http-method>
      <http-method>PUT</http-method>
      <http-method>OPTIONS</http-method>
      <http-method>TRACE</http-method>
      <http-method>DELETE</http-method>
    </web-resource-collection>
    <auth-constraint>
      <description>has to be a USER</description>
      <role-name>USERS</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>userauth</realm-name>
  </login-config>

  <security-role>
    <role-name>USERS</role-name>
  </security-role>

但不知何故,这件事不适用于 Solr 访问。我没有得到身份验证对话框,这很奇怪,因为它在另一个设置中工作。

一般来说,这种保护 Solr 实例的方法是一种好方法还是我应该尝试另一种方法?在Solr 安全页面中,他们讨论了 Solr 实例的防火墙。我不是 Linux 管理员,但我认为 iptables 将是一个可能的解决方案,并且有一些关于serverfault的不错的答案(例如这个)。

你怎么看?

4

1 回答 1

0

好的,我的解决方案实际上是使用防火墙而不是以某种方式修改 Solr。

于 2012-01-05T08:55:35.030 回答