2011-06-16 48 views
0

我有一個Apache Solr實例部署在Glassfish中,我通過Solrj從Java代碼使用此Solr實例。問題是,我想限制對Solr的訪問,以便只有這個Java代碼可以訪問它(代碼可以從不同的IP地址運行)。限制Glassfish中的Apache Solr訪問。基本身份驗證與防火牆

我的第一個想法是將我部署的Solr實例的web.xml更改爲使用Glassfish的基於文件的Realm添加基本身份驗證,因爲我使用它來限制對另一個項目中的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 Security page中,他們談論防火牆Solr實例。我不是Linux管理員,但我認爲iptables是一個可能的解決方案,並且在serverfault(例如this one)上有一些很好的答案。

您認爲如何?

回答

0

好的,我的解決方案實際上是使用防火牆,而不是以某種方式修改Solr。