solrsunspot-solr

How to set Apache solr admin password


I an not very familiar with solr. I have installed solr successfully. It is using jetty webserver. My solr version is 4.10.3. It admin page is not protected by password. Anyone can access it. I want to apply a paaword on solr admin. How I will do it?


Solution

  • For version below 5

    If you are using solr-webapp then you need to modify web.xml file and add these lines:

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

    For Jetty server, you need to add below lines in /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>
    

    Update /example/etc/jetty.xml file

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

    /example/etc/realm.properties :

    admin: s3cr3t, admin-role
    

    Username = admin password = s3cr3t. Role name = admin-role

    Solr version 5+

    In latest Solr version folder structure got changed. You will find all files in below folder-path.

    {SOLR_HOME}/server/etc/jetty.xml {SOLR_HOME}/server/etc/webdefault.xml

    Create new credential file at {SOLR_HOME}/server/etc/realm.properties:

    admin: s3cr3t, admin-role
    

    For more info you can help solr wiki docs