EDITORIAL
Many people may at times use solr, have not set a password, because, after solr to build complete, the console is no default password set. In this way, with a very easy, why do solr console login password? First, in order to secure the data because, once as long as people know your ip, you can go directly to the console, your data operations; secondly, it is to prevent hackers through your server solr dark, bloody lessons, when you run into, you know how messed up, but online there how by solr vulnerability, an attacker tutorial of someone else's server. So, take precautions, make early morning peace of mind! Otherwise, too late, too late to whom the!
First, in the WEB solr configuration files, settings, open the login configuration
File Path: /fitness/serve/solr-7.7.0/server/solr-webapp/webapp/WEB-INF/web.xml
New content:
<!-- 设置密码·B -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr Add Lock</web-resource-name>
<url-pattern>/</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Solr Admin</realm-name>
</login-config>
<!-- 设置密码·E -->
Location: Save </ web-app> this tag.
Second, create a file to store the password password.properties
file path:
/fitness/serve/solr-7.7.0/server/etc
Create a file:
vim password.properties
Add Content:
#userName:password,role
admin:MD5:9b962829040b12d3c46f4010c2b11448,admin 【md5加密登录设置定义】
或
admin:sdfeduj887sdd,admin【明文密码登录设置定义】
Third, set the login service, the introduction of password configuration file
File Path: /fitness/serve/solr-7.7.0/server/contexts/solr-jetty-context.xml
Security Configuration:
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">加载密码配置文件</Set>
<!-- 引入密码文件 -->
<Set name="config">
<SystemProperty name="jetty.home" default="."/>
/etc/real.properties
</Set>
</New>
</Set>
</Get>
Complete content:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="hostContext" default="/solr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">密码文件引入</Set>
<!-- 引入密码文件 -->
<Set name="config">
<SystemProperty name="jetty.home" default="."/>
/etc/real.properties
</Set>
</New>
</Set>
</Get>
</Configure>
Any time you have finished changing the configuration file, remember to restart the service! Such services -solr to take effect!
Fourth, browser access, view, the login window appears, indicating successful
Enter here admin and password you set up, you can log!
V. Additional information
It should be noted that, even if you password file, write the MD5 encrypted cipher text, there are also just plain text password, you can!
MD5 encryption, you can use the tool to generate relevant, of course, to use other encryption methods can be!