2012-05-27 18 views
7

Do produkcji, nie jest bezpieczne mieć administratora solr, który nawet nie pyta o login. Jak mogę wyłączyć domyślną stronę administratora solr? Po prostu chcę, aby moja aplikacja internetowa używała Solr do indeksowania wyszukiwanych haseł.Jak wyłączyć stronę administratora solr

Odpowiedz

10

Wysoce sugeruję prowadzenie strony administratora w celu debugowania. Uratowało mnie to w wielu przypadkach. Istnieją sposoby na ograniczenie go tylko do użytkowników uwierzytelnionych przez HTTP: http://wiki.apache.org/solr/SolrSecurity#Jetty_example. Być może będziesz musiał rozpakować i ponownie skompresować swoją aplikację internetową.

Jeśli jednak nadal chcesz wyłączyć całą sekcję administratora, możesz skomentować polecenie request_administratora w $ {SOLR_HOME} /project/solr/conf/solrconfig.xml.

2

Możesz chronić swoją stronę administratora hasłem, dodając ograniczenie bezpieczeństwa do aplikacji internetowej Solr.

krótkiego opisu dla 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> 

W Solr 4 trzeba chronić następujące zasoby dla interfejsu admin:

/admin/* 
/admin.html 
+0

w jakim plik, aby dodać ten fragment kodu? – tasmaniski

+0

To byłby plik web.xml. Nie jestem pewien co do konfiguracji pomostu. – Maddin

-3

Najłatwiej:

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

iptables -A INPUT -p tcp -s 127.0.0.1 --dport 8983 -j AKCEPTUJ

z tym zamówieniem!

+0

Gdy próbowałem tego, moje skrypty w witrynie nie były już w stanie uzyskać dostępu do Solr - trochę grałem z iptables próbując różnych adresów IP i innych rzeczy bezskutecznie (być może z powodu braku wiedzy eksperckiej na ten temat). Wciąż szukam łatwej odpowiedzi bez powodzenia, daleko ... – JxAxMxIxN

+0

Ponieważ zła kolejność. Tutaj oneliner: 'iptables -A INPUT -p tcp -s localhost --dport 8983 -j ACCEPT && iptables -A INPUT -p tcp --dport 8983 -j DROP && iptables-save> iptables.rules && iptables-restore hlcs

0

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

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

do

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

następnie usługa sudo solrd restart

Powiązane problemy