如何设置Apache solr admin 使用需要密码

我已经安装了Solr,使用Jetty服务器。我的Solr版本4.10.3。它管理页面不受密码保护。任何人都可以访问它。我想使用时Solr管理员输入密码,才能使用如何实现?
已邀请:

赞同来自: 沐予 z00001993518 uniyu liuxc2016 slj123 jeking更多 »


If you are using solr-webapp then you need to modify web.xml file and add below 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>


If you are running solr using jetty server then you need to modify /example/etc/webdefault.xml and add below lines


<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>core1-role</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>


And you need to modify jetty.xml file as well from /example/etc/jetty.xml


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


add properties file /example/etc/realm.properties


admin: s3cr3t, admin-role

Username: admin
password: s3cr3t

要回复讨论请先登录注册